[build2] Novice setting up unpackaged dependency GLFW
Thomas Cairns
lazycairx at gmail.com
Mon Apr 13 11:25:33 UTC 2020
QUESTION / PROBLEM
--------------------------------------------------
Hello, I'm running into issues setting up a project to use GLFW as an
unpackaged dependency.
I'm a complete beginner at using build2. This is the first project I'm
trying to setup. I have used C++ for a few years, but have never gotten
very comfortable with all the C++ toolchains.
Any form of help would be greatly appreciated.
(Since the documentation became larger than anticipated I made a copy
as a gist https://gist.github.com/CairX/3e9704c00d8709b8baea664ad53bf508)
INFORMATION
--------------------------------------------------
The information I have used to try and get the project setup is based on
the official documentation:
https://www.build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-unpackaged-deps
And an earlier mailing list I found here:
https://lists.build2.org/archives/users/2018-December/000547.html
SETUP
--------------------------------------------------
$ pwd
/tmp/workspace
$ mkdir unpkg-gcc
$ git clone https://github.com/glfw/glfw.git
$ cd glfw
$ git checkout 3.3.2
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/tmp/workspace/unpkg-gcc /tmp/workspace/glfw
$ make install
$ cd /tmp/workspace
$ tree unpkg-gcc
unpkg-gcc
├── include
│ └── GLFW
│ ├── glfw3.h
│ └── glfw3native.h
└── lib
├── cmake
│ └── glfw3
│ ├── glfw3Config.cmake
│ ├── glfw3ConfigVersion.cmake
│ ├── glfw3Targets.cmake
│ └── glfw3Targets-noconfig.cmake
├── libglfw3.a
└── pkgconfig
└── glfw3.pc
6 directories, 8 files
$ bdep new -t exe -l c++ hello
$ cd hello
$ bdep init -C ../hello-gcc @gcc cc config.cxx=g++
config.cc.poptions=-I/tmp/workspace/unpkg-gcc/include
config.cc.loptions=-L/tmp/workspace/unpkg-gcc/lib
initializing in project /tmp/workspace/hello/
created configuration @gcc /tmp/workspace/hello-gcc/ 1
default,forwarded,auto-synchronized
synchronizing:
new hello/0.1.0-a.0.19700101000000
$ b
mkdir ../hello-gcc/hello/fsdir{hello/}
c++ hello/cxx{hello}@../hello-gcc/hello/hello/
ld ../hello-gcc/hello/hello/exe{hello}
ln ../hello-gcc/hello/hello/exe{hello} -> hello/
$ hello/hello World
Hello, World!
ADJUSTMENT NR 1
--------------------------------------------------
In the documentation it mentions:
"Once this is done, adjust your buildfile to import the library:
import libs += libextra%lib{extra}"
I took this to mean /tmp/workspace/hello/buildfile
$ cat buildfile
./: {*/ -build/} doc{README.md} manifest
import libs += GLFW%lib{glfw3}
And adjusted main file to use GLFW.
$ cat hello/hello.cxx
#include <GLFW/glfw3.h>
int main(int argc, char * argv[])
{
glfwInit();
glfwInitHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow * window = glfwCreateWindow(800, 600, "Hello", NULL, NULL);
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
$ b
c++ hello/cxx{hello}@../hello-gcc/hello/hello/
ld ../hello-gcc/hello/hello/exe{hello}
/usr/bin/ld: ../hello-gcc/hello/hello/hello.o: in function `main':
hello.cxx:(.text+0x10): undefined reference to `glfwInit'
/usr/bin/ld: hello.cxx:(.text+0x1f): undefined reference to `glfwInitHint'
/usr/bin/ld: hello.cxx:(.text+0x40): undefined reference to
`glfwCreateWindow'
/usr/bin/ld: hello.cxx:(.text+0x50): undefined reference to
`glfwWindowShouldClose'
/usr/bin/ld: hello.cxx:(.text+0x5e): undefined reference to `glfwPollEvents'
/usr/bin/ld: hello.cxx:(.text+0x6c): undefined reference to
`glfwDestroyWindow'
/usr/bin/ld: hello.cxx:(.text+0x71): undefined reference to `glfwTerminate'
collect2: error: ld returned 1 exit status
info: failed to update ../hello-gcc/dir{hello/}
ADJUSTMENT NR 2
--------------------------------------------------
The documentation mentions that the -L option alone should be enough if
there the packages include a .pc file. Since this one does I thought
it might reduce the number of moving parts to remove the -I option.
So reset config.cc.poptions = [null] in
/tmp/workspace/hello-gcc/build/config.build
$ b
error: header 'GLFW/glfw3.h' not found and cannot be generated
info: re-run with --verbose=4 for more information
info: while extracting header dependencies from hello/cxx{hello}@
../hello-gcc/hello/hello/
info: while applying rule cxx.compile to update
../hello-gcc/hello/hello/obje{hello}
info: while applying rule cxx.link to update
../hello-gcc/hello/hello/exe{hello}
info: while applying rule alias to update ../hello-gcc/hello/dir{hello/}
info: while applying rule alias to update ../hello-gcc/dir{hello/}
info: failed to update ../hello-gcc/dir{hello/}
Which made me think that the -I option was just giving me a false
positive. After searching a looking around a lot I remembered seeing a
commented out import line in /tmp/workspace/hello/hello/buildfile.
Decided to try moving my import there instead.
$ b
error: package 'xproto', required by 'x11', not found
info: while applying rule cxx.link to update
../hello-gcc/hello/hello/exe{hello}
info: while applying rule alias to update ../hello-gcc/hello/dir{hello/}
info: while applying rule alias to update ../hello-gcc/dir{hello/}
error: package 'kbproto', required by 'x11', not found
info: while applying rule cxx.link to update
../hello-gcc/hello/hello/exe{hello}
info: while applying rule alias to update ../hello-gcc/hello/dir{hello/}
info: while applying rule alias to update ../hello-gcc/dir{hello/}
info: failed to update ../hello-gcc/dir{hello/}
Which seems to have moved me in the right direction as it seems to be
trying to incorporate GLFW into the build this time.
ADJUSTMENT NR 3
--------------------------------------------------
I have been investigating a lot into why the packages might not be found.
Checking that the correct packages are installed which should be
x11proto-core-dev which is a dependency of xorg-dev.
$ apt info xorg-dev
Package: xorg-dev
Version: 1:7.7+19
Priority: optional
Section: x11
Source: xorg
Maintainer: Debian X Strike Force <debian-x at lists.debian.org>
Installed-Size: 47.1 kB
Depends: libdmx-dev, libfontenc-dev, libfs-dev, libice-dev, libsm-dev,
libx11-dev, libxau-dev, libxaw7-dev, libxcomposite-dev, libxcursor-dev,
libxdamage-dev, libxdmcp-dev, libxext-dev, libxfixes-dev, libxfont-dev,
libxft-dev, libxi-dev, libxinerama-dev, libxkbfile-dev, libxmu-dev,
libxmuu-dev, libxpm-dev, libxrandr-dev, libxrender-dev, libxres-dev,
libxss-dev, libxt-dev, libxtst-dev, libxv-dev, libxvmc-dev,
libxxf86dga-dev, libxxf86vm-dev, x11proto-bigreqs-dev,
x11proto-composite-dev, x11proto-core-dev, x11proto-damage-dev,
x11proto-dmx-dev, x11proto-fixes-dev, x11proto-fonts-dev, x11proto-gl-dev,
x11proto-input-dev, x11proto-kb-dev, x11proto-randr-dev,
x11proto-record-dev, x11proto-render-dev, x11proto-resource-dev,
x11proto-scrnsaver-dev, x11proto-video-dev, x11proto-xcmisc-dev,
x11proto-xext-dev, x11proto-xf86bigfont-dev, x11proto-xf86dga-dev,
x11proto-xf86dri-dev, x11proto-xf86vidmode-dev, x11proto-xinerama-dev,
xserver-xorg-dev, xtrans-dev
Homepage: http://www.x.org/
Tag: devel::library, role::devel-lib, role::metapackage
Download-Size: 38.2 kB
APT-Manual-Installed: yes
APT-Sources: http://deb.debian.org/debian buster/main amd64 Packages
Description: X.Org X Window System development libraries
This metapackage provides the development libraries for the X.Org X Window
System.
.
X Window System design documentation, manual pages, library reference
works, static versions of the shared libraries, and C header files are
supplied by the packages depended on by this metapackage.
.
Note that this is a convenience package for users and is not a package for
Debian developers to have their package depend on.
That the .pc-files exists:
$ ls -l /usr/share/pkgconfig/kbproto.pc
-rw-r--r-- 1 root root 173 Apr 3 2018 /usr/share/pkgconfig/kbproto.pc
$ ls -l /usr/share/pkgconfig/xproto.pc
-rw-r--r-- 1 root root 203 Apr 3 2018 /usr/share/pkgconfig/xproto.pc
That pkg-config looks in the correct location:
$ pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
And made sure that the path is in the environmental variable:
$ echo $PKG_CONFIG_PATH
/usr/share/pkgconfig
This is where I'm at a loss.
Best regards,
Thomas Cairns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.build2.org/archives/users/attachments/20200413/ba6e664c/attachment.html>
More information about the users
mailing list