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

后端 未结 2 2070
清酒与你
清酒与你 2021-02-12 12:39

I successfully compiled and installed the latest version of the Boost library onto my linux machine. Now, I would like to be able to use pkg-config to ease the process of provid

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-12 13:15

    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-config
    
    prefix=/usr/local/Cellar/boost/1.60.0_2
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib
    includedir_old=${prefix}/include/boost
    includedir_new=${prefix}/include
    
    Name: Boost
    Description: Boost is awesome
    Version: 1.60.0
    Libs: -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-mt
    Cflags: -I${includedir_old} -I${includedir_new}
    

提交回复
热议问题