[build2] Novice setting up unpackaged dependency GLFW

Boris Kolpackov boris at codesynthesis.com
Mon Apr 13 14:17:39 UTC 2020


Thomas Cairns <lazycairx at gmail.com> writes:

> (Since the documentation became larger than anticipated I made a copy
> as a gist https://gist.github.com/CairX/3e9704c00d8709b8baea664ad53bf508)

Thanks for going into such a level of detail, it definitely makes
reproducing easier.


> 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

That would actually be /tmp/workspace/hello/hello/buildfile (i.e.,
the buildfile that builds the library; it even has a commented
out example of import inside). But I see you've figured that our
below.


> 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 the problem is: those .pc files are in a directory where
build2 does not search by default. Also note that build2 doesn't use
pkg-config (it uses the libpkgconf library instead) nor recognizes
PKG_CONFIG_PATH (in order to keep library/.pc file search paths
consistent).

I looked into xproto.pc and kbproto.pc and they appear to be header-
only-like libraries that, at least both on Debain and Fedora, are
installed under /usr/share/ rather than /usr/lib/ (where build2
would have found them).

We have a similar issue on FreeBSD where the .pc files are installed
into ../libdata/pkgconfig/. Seeing that this is an analogous situation
I went ahead and added ../share/pkgconfig/ for Linux. So your example
should work out of the box in the next release (and with the tomorrow's
update of the staged toolchain[1], if you would like to give it a try).

Now what to do for 0.12.0 (the current release)? The simplest workaround
would probably be to symlink these two .pc files in /usr/lib/pkgconfig/.
Specifically, after running these two commands I was able to build your
example:

$ sudo ln -s /usr/share/pkgconfig/xproto.pc /usr/lib/pkgconfig/
$ sudo ln -s /usr/share/pkgconfig/kbproto.pc /usr/lib/pkgconfig/

Just for completeness, with the staged toolchain (even from today) you
could also pass -L/usr/share as a dummy system search directory like
this:

$ bdep init -C ../hello-gcc @gcc cc \
config.cxx="g++ -L/usr/share"       \
config.cc.loptions=-L/tmp/workspace/unpkg-gcc/lib

While there are no actually libraries in this directory, this adds
/usr/share/pkgconfig/ as a .pc search directory. Note that this
ability to pass additionally search directories as part of config.cxx
(called "compiler mode"; this also causes them to be treated as system)
is not yet available in 0.12.0.


[1] https://build2.org/community.xhtml#stage



More information about the users mailing list