Re: [Boost-bugs] [Boost C++ Libraries] #1094: Finding the correct library to link (feature request for pkg-config support)h

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1094: Finding the correct library to link (feature request for pkg-config support)h
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-07-25 17:43:24


#1094: Finding the correct library to link (feature request for pkg-config
support)h
--------------------------------+-------------------------------------------
  Reporter: rleigh@… | Owner: vladimir_prus
      Type: Feature Requests | Status: assigned
 Milestone: Boost 1.42.0 | Component: build
   Version: | Severity: Problem
Resolution: | Keywords: pkg-config linking library naming
--------------------------------+-------------------------------------------

Comment (by anonymous):

 This gives:

 boost-pkg-config-gen.cc: In function ‘int main()’:
 boost-pkg-config-gen.cc:20: error: ‘BOOST_VERSION’ was not declared in
 this scope
 boost-pkg-config-gen.cc:24: error: ‘boost::pkg_config’ has not been
 declared
 boost-pkg-config-gen.cc:25: error: ‘boost::pkg_config’ has not been
 declared


 Replying to [comment:19 Roger Leigh <rleigh@…>]:
> With the above two attachments, you can do this:
>
> {{{
> % g++ -DTEST_LIBRARY='"boost_filesystem"'
 -DTEST_HEADER='<boost/filesystem.hpp>' -o boost-pkg-config-gen boost-pkg-
 config-gen.cc -lboost_filesystem
> % ./boost-pkg-config-gen > boost_filesystem.pc
> % cat boost_filesystem.pc
> prefix=/usr
> exec_prefix=${prefix}
> libdir=/usr/lib
> includedir=${prefix}/include
>
> Name: boost_filesystem
> Description: Boost C++ libraries (boost_filesystem)
> Version: 1.42.0
> Libs: -L${libdir} -lboost_filesystem -lboost_system
> Cflags: -I${includedir}
> }}}
>
> Notice that it's correctly picked out the boost_filesystem and
 boost_system dependencies.
>
> The auto_link.hpp change causes any required libraries to be stored in a
 boost::pkg_config::library_list class. This is only created if
 BOOST_PKG_CONFIG_DUMP is defined, so has zero overhead for normal users.
>
> Note, boost/random/detail/auto_link.hpp and
 boost/iostreams/detail/config/auto_link.hpp may need adjusting as for
 boost/config/auto_link.hpp so that it's not skipped for non-MSVC/Borland
 compilers. All compilers should now process boost/config/auto_link.hpp.
 The object created to trigger list updates could also be put into the
 anonymous namespace.
>
> The test program needs these macros defining:
>
> * TEST_LIBRARY - library name
> * TEST_HEADER - header to include
> * PREFIX - install prefix (currently hardcoded)
> * LIBDIR - library directory (currently hardcoded)
> * include path and exec prefix may also require defining (again
 currently hardcoded)
>
> I don't know how to use the Boost build system to integrate this
 directly (I'm a make person I'm afraid), or else I'd do that in the patch.
 If the various path prefixes are known to the build system, they can be
 passed directly during compilation (I didn't see them stored in any
 headers).
>
> So, it's now possible to run the program for each boost module (name and
 primary header) and get a .pc file generated for it. These need
 installing in prefix/lib/pkgconfig. Note that this test program needs
 linking with *every* boost shared object available, since we don't know in
 advance which will be needed for a given combination of headers (this
 being the point of the excercise in the first place).
>
> This doesn't use more advanced features such as Requires (which would
 allow for nested inclusion of .pc files), but this isn't really required.
>
> Also, pkg-config files may be created for all Boost libraries
 irrespective of whether they have a shared object or not. The include
 path etc. are still useful.
>
> One implication this scheme has is that the .pc files can't be generated
 when cross-compiling unless run on the host post-build. However, it's
 about the best we can do without direct compiler support for the auto-link
 scheme used by MSVC/Borland.
>
> I hope this useful for inspiration if it's not directly usable for you
 as is.
>
>
> Regards,
> Roger Leigh
>
> (Thanks are also due to a number of other Debian developers who spent
 some time with me trying to find solutions utilising the C preprocessor
 only. Unfortunately, we didn't find a clean way to do that.)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/1094#comment:25>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC