[build2] pkgconfig files, header-only libraries, and cppget's boost packages

Michael Martín Moro sexymimi64 at gmail.com
Tue Sep 27 11:52:23 UTC 2022

Alright, thanks ! I think I wasn't explicit enough: the issue is
specifically that header-only libraries are referenced in the `Libs` field
of pkg-config files.

It makes sense to forward non-header-only dependencies of header-only
libraries to their pkgconfig file. But what I'm seeing is that the
header-only libraries themselves are being pulled into the `Libs` fields.
And I'm pretty sure that doesn't make sense: for instance, the lexical_cast
boost library is header only, so the `libboost_lexical_cast.so` file will
never exist. Hence I would assume that writing "-lboost_lexical_cast"
anywhere wouldn't make sense. Yet the `Libs` field of the generated
pkgconfig files are filled with such references to header-only libraries.

And the result is that those pkgconfig files cannot be used by the
pkg-config module for CMake. The linking step cannot complete if one of the
referenced lib cannot be found. And `-lboost_lexical_cast`, along with many
others, won't be found.

For reference, here is the pc file for libboost_program_options:

Name: libboost-program-options
Version: 1.78.0
Description: The program_options library allows program developers to
obtain program options, that is (name, value) pairs from the user, via
conventional methods such as command line and config file
URL: https://github.com/boostorg/program_options
Cflags: -I/home/michael/tintin/build-clang++-14/pkg/include
Libs: -L/home/michael/tintin/build-clang++-14/pkg/lib
-lboost_program_options -lboost_any -lboost_function -lboost_bind
-lboost_type_index -lboost_lexical_cast -lboost_container -lboost_intrusive
-lboost_numeric_conversion -lboost_range -lboost_array -lboost_iterator
-lboost_conversion -lboost_fusion -lboost_function_types -lboost_tuple
-lboost_typeof -lboost_optional -lboost_regex -licui18n -licuuc
-lboost_concept_check -lboost_container_hash -lboost_detail -lboost_integer
-lboost_mpl -lboost_utility -lboost_io -lboost_preprocessor
-lboost_smart_ptr -lboost_move -lboost_core -lboost_throw_exception
-lboost_assert -lboost_winapi -lboost_predef -lboost_type_traits
-lboost_static_assert -lboost_config
Libs.private: -lboost_tokenizer -licudata -lpthread -ldl -lm

build2.metadata = 1

cc.type = cxx

cxx.importable_headers = \

The `Libs` field includes tokens such as -lboost_bind,
-lboost_lexical_cast, -lboost_core, which are header-only libraries. I
don't think these tokens should be included.

I have a workaround for that, which consists in using a script to prune all
the "-l[insert header-only library name here]" from all the generated pc
files. But I believe this is an issue.

El lun, 26 sept 2022 a las 15:30, Boris Kolpackov (<boris at codesynthesis.com>)

> Michael Martín Moro via users <users at build2.org> writes:
> > They use `import intf_libs` or `import impl_libs` for importing all boost
> > dependencies... including header only ones.
> >
> > Seems to me like it resuls in pkgconfig files including a lot of extra
> > library to link that do not exist. You can check it out with
> > libboost-program-options or libboost-random: there are some -lboost_any
> > here and -lboost_config there that shouldn't be there.
> No, this is by design. We list header-only libraries in pkg-config files
> in order to load their own pkg-config files, which may (1) export some
> preprocessor options (-I, -D) or (2) link non-header-only libraries that
> they may depend upon (in build2 header-only libraries can depend on non-
> header-only).
> > It is my understanding that those header-only libraries should be
> imported
> > using `import libs` instead.
> There is nothing special about intf_libs/impl_libs/libs after import,
> they are just variable names. By convention we use intf_libs/impl_libs
> in libraries where it's required to separate interface (intf) and
> implementation (impl) libraries and we use libs in executables where
> such a separation isn't needed. For background, see:
> https://build2.org/build2/doc/build2-build-system-manual.xhtml#intro-lib

*Michaël Martín Moro*
{ Epitech. Tek4 }
{ UCA Cadíz - Computer Engineering }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.build2.org/archives/users/attachments/20220927/14139b88/attachment.html>

More information about the users mailing list