如何使用 CMake 将 C++ 程序与 Boost 链接起来
问题描述
在 Ubuntu 下将我的程序与 Boost 库链接起来时,我的 CMake 文件应该是什么样的?
What should my CMake file look like for linking my program with the Boost library under Ubuntu?
运行make
时显示的错误:
主文件非常简单:
<小时>
我已经做到了.我添加到我的 CMake 文件中的唯一几行是:
I've managed to do that. The only lines that I've added to my CMake files were:
推荐答案
在 CMake 中,您可以使用 find_package
来查找您需要的库.通常有一个 FindBoost.cmake
与您的 CMake 安装一起.
In CMake you could use find_package
to find libraries you need. There usually is a FindBoost.cmake
along with your CMake installation.
据我所知,它将与其他公共库的查找脚本一起安装到 /usr/share/cmake/Modules/
.您可以查看该文件中的文档,了解有关其工作原理的更多信息.
As far as I remember, it will be installed to /usr/share/cmake/Modules/
along with other find-scripts for common libraries. You could just check the documentation in that file for more information about how it works.
我脑海中的一个例子:
我希望这段代码有帮助.
I hope this code helps.
- 这是关于 FindBoost.cmake 的官方文档.
- 和实际的 FindBoost.cmake(托管在 GitHub 上))
- Here's the official documentation about FindBoost.cmake.
- And the actual FindBoost.cmake (hosted on GitHub)
这篇关于如何使用 CMake 将 C++ 程序与 Boost 链接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!