Finding the correct library to link (feature request for pkg-config support)
Hi folks,
[I've posted this to both user and development lists, because I'm not
sure which is most appropriate in this case.]
I make use of several Boost libraries in my schroot program
(svn://svn.debian.org/svn/buildd-tools/trunk/schroot).
This project, like many, utilises GNU Autoconf and Automake for its
build system. I need to determine how to link with the Boost
libraries in order to build the programs in the project. This is an
issue for many projects which want to link with a Boost library.
To illustrate my problem:
ls -l /usr/lib/libboost_regex-*.so /usr/lib/libboost_program_options-*.so
lrwxrwxrwx 1 root root 45 2007-07-08 11:48 /usr/lib/libboost_program_options-gcc41-1_34.so -> libboost_program_options-gcc41-1_34.so.1.34.0
lrwxrwxrwx 1 root root 48 2007-07-08 11:48 /usr/lib/libboost_program_options-gcc41-mt-1_34.so -> libboost_program_options-gcc41-mt-1_34.so.1.34.0
lrwxrwxrwx 1 root root 41 2007-07-08 11:48 /usr/lib/libboost_program_options-mt.so -> libboost_program_options-gcc41-mt-1_34.so
lrwxrwxrwx 1 root root 38 2007-07-08 11:48 /usr/lib/libboost_program_options-st.so -> libboost_program_options-gcc41-1_34.so
lrwxrwxrwx 1 root root 35 2007-07-08 11:47 /usr/lib/libboost_regex-gcc41-1_34.so -> libboost_regex-gcc41-1_34.so.1.34.0
lrwxrwxrwx 1 root root 38 2007-07-08 11:47 /usr/lib/libboost_regex-gcc41-mt-1_34.so -> libboost_regex-gcc41-mt-1_34.so.1.34.0
lrwxrwxrwx 1 root root 31 2007-07-08 11:47 /usr/lib/libboost_regex-mt.so -> libboost_regex-gcc41-mt-1_34.so
lrwxrwxrwx 1 root root 28 2007-07-08 11:47 /usr/lib/libboost_regex-st.so -> libboost_regex-gcc41-1_34.so
Unlike every other library on my system, the Boost libraries have the
compiler (gcc41) and threading model (mt|st) and so on embedded *in
the library name*. This makes it impossible to discover in an
automatic fashion. Since this is free software anyone can download
and build, I don't know what the compiler/toolchain will be, let alone
what abbreviation Boost has chosen for it. I expect that Autoconf
will set up such things appropriately.
The only means I have are the libboost_program_options-mt.so,
libboost_program_options-st.so (and so on for all the libraries)
symbolic links which the Debian maintainer has helpfully provided.
However, these are not portable, and are so not a good solution. They
are, however, the only available solution at the moment.
To further show the problem I am having, this is part of my
configure.ac Autoconf template:
---configure.ac----
AC_CHECK_HEADERS([tr1/memory])
AC_CHECK_HEADERS([boost/shared_ptr.hpp],, [
if test $ac_cv_header_tr1_memory = yes; then
:
else
AC_MSG_ERROR([Boost.shared_ptr (Boost C++ Libraries) is not installed, but is required by schroot])
fi])
AC_CHECK_HEADERS([tr1/tuple])
AC_CHECK_HEADERS([boost/tuple/tuple.hpp],, [
if test $ac_cv_header_tr1_memory = yes; then
:
else
AC_MSG_ERROR([Boost.Tuple (Boost C++ Libraries) is not installed, but is required by schroot])
fi])
AC_CHECK_HEADERS([boost/format.hpp],, [AC_MSG_ERROR([Boost.Format (Boost C++ Libraries) is not installed, but is required by schroot])])
AC_CHECK_HEADERS([boost/program_options.hpp],, [AC_MSG_ERROR([Boost.Program_options (Boost C++ Libraries) is not installed, but is required by schroot])])
AC_CHECK_HEADERS([boost/type_traits.hpp],, [AC_MSG_ERROR([Boost.TypeTraits (Boost C++ Libraries) is not installed, but is required by schroot])])
AC_MSG_CHECKING([for boost::program_options::variables_map in -lboost_program_options-st])
saved_ldflags="${LDFLAGS}"
LDFLAGS="${LDFLAGS} -lboost_program_options-st"
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include
on Sat Jul 14 2007, Roger Leigh
It would be great if Boost would provide a mechanism to allow such discovery. Such a mechanism already exists, and is called "pkg-config". By installing a small file in LIBDIR/pkgconfig for each Boost library, the pkg-config tool or PKG_CHECK_MODULES Autoconf macro may be used to query this information.
Please enter all of the material in your post into a ticket at svn.boost.org It's important, and I don't want it to get lost. Thanks, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
David Abrahams
on Sat Jul 14 2007, Roger Leigh
wrote: It would be great if Boost would provide a mechanism to allow such discovery. Such a mechanism already exists, and is called "pkg-config". By installing a small file in LIBDIR/pkgconfig for each Boost library, the pkg-config tool or PKG_CHECK_MODULES Autoconf macro may be used to query this information.
Please enter all of the material in your post into a ticket at svn.boost.org It's important, and I don't want it to get lost.
Done. It's at http://svn.boost.org/trac/boost/ticket/1094 Regards, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
participants (2)
-
David Abrahams
-
Roger Leigh