How to use C++ Boost library with pkg-config? How to use C++ Boost library with pkg-config? linux linux

How to use C++ Boost library with pkg-config?


What you're looking for seems to be a bit complicated, and a long-requested feature, as indicated in this 3 year old post https://svn.boost.org/trac/boost/ticket/1094 on Boost's trac. Reading through it shows that the feature was repeatedly postponed and never implemented (as of 1.4.3). The cause of the inability to generate a .pc file usable by pkg-config happens to do with boost's inconsistency in naming their library versions / build variants.

FWIW, an alternative for "automating" your building process is to use autotools (autoconf/automake). There's a link that might be of use to you (which I can't post because SO thinks I'm a spammer instead of a newcomer!), just google "tsuna boost m4 github" and it should take you there :)


Was facing a similar issue with boost. Wrote simple python script to generate a .pc file. Saved me the pain of having write all the linker commands. I've posted it on https://github.com/nmante/pkg-config-generator.

Essentially, you give the script a directory where the library files are (.so, .a, .dylib files) and it will generate the linker commands (e.g. -lboost_graph). Feel free to tweak and fork to your needs.

Here's a sample boost.pc file I generated for my machine (Mac OS X). You can tweak it manually, or you can use my github program to generate it on your machine.

# Package Information for pkg-configprefix=/usr/local/Cellar/boost/1.60.0_2exec_prefix=${prefix}libdir=${exec_prefix}/libincludedir_old=${prefix}/include/boostincludedir_new=${prefix}/includeName: BoostDescription: Boost is awesomeVersion: 1.60.0Libs: -L${exec_prefix}/lib  -lboost_prg_exec_monitor-mt -lboost_math_c99f-mt -lboost_unit_test_framework-mt -lboost_container-mt -lboost_log_setup -lboost_math_tr1l -lboost_graph-mt -lboost_wserialization-mt -lboost_log-mt -lboost_math_c99f -lboost_type_erasure -lboost_signals-mt -lboost_test_exec_monitor -lboost_filesystem -lboost_thread-mt -lboost_math_tr1f-mt -lboost_date_time -lboost_timer -lboost_math_tr1f -lboost_test_exec_monitor-mt -lboost_container -lboost_math_tr1 -lboost_type_erasure-mt -lboost_program_options-mt -lboost_graph -lboost_log_setup-mt -lboost_random -lboost_system -lboost_system-mt -lboost_locale-mt -lboost_wserialization -lboost_regex -lboost_exception -lboost_timer-mt -lboost_signals -lboost_filesystem-mt -lboost_math_c99-mt -lboost_math_tr1-mt -lboost_serialization-mt -lboost_serialization -lboost_prg_exec_monitor -lboost_exception-mt -lboost_coroutine -lboost_math_c99 -lboost_iostreams-mt -lboost_random-mt -lboost_program_options -lboost_atomic-mt -lboost_date_time-mt -lboost_math_c99l -lboost_math_tr1l-mt -lboost_context-mt -lboost_regex-mt -lboost_coroutine-mt -lboost_log -lboost_chrono-mt -lboost_wave-mt -lboost_iostreams -lboost_chrono -lboost_unit_test_framework -lboost_math_c99l-mtCflags: -I${includedir_old} -I${includedir_new}