首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何通过pkg-config使用C++ Boost库?

如何通过pkg-config使用C++ Boost库?
EN

Stack Overflow用户
提问于 2010-10-20 02:59:18
回答 1查看 13K关注 0票数 21

我成功地编译了最新版本的Boost库,并将其安装到了我的linux机器上。现在,我希望能够使用pkg-config来简化与GCC提供链接参数的过程。

既然我懒得手动编写自己的.pc文件,有没有脚本/工具可以自动生成所需的.pc文件,或者以其他方式使用boost标志更新pkg-config?

(如果有人已经拥有该.pc文件,也欢迎共享。)

EN

回答 1

Stack Overflow用户

发布于 2016-06-25 19:53:31

boost也面临着类似的问题。编写简单的python脚本来生成.pc文件。省去了我编写所有链接器命令的痛苦。我已经把它贴到https://github.com/nmante/pkg-config-generator上了。

从本质上讲,你给脚本一个库文件(.so、.a、.dylib文件)所在的目录,它就会生成链接器命令(例如-lboost_graph)。您可以根据自己的需求进行调整和分支。

下面是我为我的机器(Mac )生成的示例boost.pc文件。您可以手动调整它,也可以使用我的github program在您的机器上生成它。

代码语言:javascript
复制
# 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}
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3971703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档