CMake 项目构建的问题
Issue with CMake project building
我有以下问题。在我的 Ubuntu 上,我尝试构建一个项目并收到以下链接器错误:
/usr/bin/ld:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_thread.a(once.o): undefined reference to symbol 'pthread_once@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO
missing from command line collect2: error: ld returned 1 exit status
make[2]: *** [sunprint] Error 1 make[1]: ***
[CMakeFiles/sunprint.dir/all] Error 2 make: *** [all] Error 2
*** Failure: Exit code 2 ***
我在 ubuntu 13 桌面下运行,GCC 4.8,提升版本是 1.54。作为我正在使用的IDE,我正在使用是KDevelop。如果需要,我可以提供有关此问题的任何其他信息,但现在我被困住了此链接问题。
有什么想法吗?提前感谢。
add_definitions
只为预处理器添加输入,预处理器甚至在编译器开始其业务之前就已经在运行,甚至离链接可执行文件更远,这是ld
应该做的。
ld
解决链接时依赖关系,您希望的是 CMake 命令 target_link_libraries
,对于给定的目标,它会添加许多库以在编译后链接。
在您的情况下,适当的调用可能如下所示
target_link_libraries(${PROJECT_NAME} [...] -lpthread [...]) #obviously without the '[...]' and the correct target name
我遇到了类似的问题,但mpich
.双:
target_link_libraries(${PROJECT_NAME} [...] -lmpich [...])
和
target_link_libraries(${PROJECT_NAME} [...] mpich [...])
工作正常。
相关文章:
- 如何解决 Ninja c++ 构建和执行问题
- macOS 上的 openvino 构建问题
- 在树莓派上用libtorch构建程序时的链接问题
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 构建LLVM 10 C++工具链的问题
- 在Visual Studio 2017中使用c ++组件构建python解决方案时出现问题
- 调试模板时出现问题.专门针对 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 错误构建失败:模板参数 1
- 构建OpenCV的基本CMakefile问题
- wxWidgets jpeg库构建问题
- exteranl原生构建问题,构建命令失败,android工作室
- 使用 Bazel (Windows) 构建 Tensorflow 的问题 => 使用 Tensorflow C++ API
- 使用 CMake 构建 {fmt} 时出现问题
- 使用 RcppArmadillo 构建 R 包的问题
- 使用 cmake 构建 dOxygen 的问题
- PCL 构建存在 boost::throw_exception 问题
- TFS构建由于链接问题而失败
- 构建Makefile的问题
- 修复了安装 OSRM 时使用"make"命令时的构建问题
- 在 MATLAB 上使用 G++ 构建时出现问题
- 在构建基于 C++ 的软件时包含 QtGui 文件的问题