编译 cmake 代码时获取"ld: symbol(s) not found for architecture x86_64"
Getting "ld: symbol(s) not found for architecture x86_64" when compiling cmake code
我正在尝试编译一个使用Boost的ROS包。代码在 Linux 上编译得很好,但在 OS X 上我收到错误
ld: symbol(s) not found for architecture x86_64
我通过brew安装了Boost,似乎它以64位安装(我的系统也是64位 - OS X 10.9),因为正在运行
file libboost_atomic-mt.dylib
输出
libboost_atomic-mt.dylib: Mach-O 64-bit dynamically linked shared library x86_64
在CMakeFiles.txt中,我已经尝试了编译和链接标志方面的几乎所有内容,尝试了-stdlib作为libc ++和libstdc++,以及-mmacosx-version-min作为从10.5到10.9的所有内容。例如,现在我有:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++ -mmacosx-version-min=10.9")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++ -mmacosx-version-min=10.9")
此外,使用 -m64 构建会产生相同的错误,使用 -m32 构建会产生相同的错误,只是它说"......架构 i136"。
以下粘贴箱分别包含我的 CMake文件.txt和编译错误:
http://pastebin.com/0MD8T916 - CMakeFiles.txt
http://pastebin.com/v3vk9i2r - 错误
我没有解决这个问题的想法了...
感谢您的帮助!
您实际上并没有在项目中添加/链接 boost 库。
set(BOOST_COMPONENTS
unit_test_framework
program_options
thread) # And other components you need
set(Boost_USE_STATIC_LIBS ON) # Easier to deploy elsewhere
set(BOOST_ROOT /usr/local/opt/boost) # Useful for boost from brew
set(BOOST_LIBRARYDIR /usr/local/opt/boost/lib64)
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(<your target> ${Boost_LIBRARIES})
相关文章:
- "error: no matching function for call to"构造函数错误
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- Android Studio 3.1.2 - 无法运行C++子例程"No implementation found for Java.lang.String..."
- Vtk 图表在 QT 中突破,"no override found for 'vtkContextDevice2D"
- NetBeans for C/C++ 说"no compiler found"
- 当 pip 安装 scikit-learn "ld: library not found for -lc++"
- Microsoft Visual Studio - 'The build tools for v140 cannot be found'
- 启用 openmp 时出错 - "ld: library not found for -lgomp" 和 Clang 错误
- 安装摩西翻译软件。错误消息:"ld: library not found for -lboost_thread"
- 有错误"Undefined symbols for architecture x86_64"和"ld: symbol(s) not found for architecture x86_64"
- Xcode 警告:"directory not found for option"
- 警告'RTTI symbol not found for class'是什么意思?
- OpenCV 3 的"ld: symbol(s) not found for architecture x86_64"
- 神秘的构建错误"symbol(s) not found for i386" - openFrameworks 像素操作
- Xcode 错误"not found for architecture" 。尝试不使用库的基本C++
- 示例 XSD 失败并显示"error: no declaration found for element X"
- 编译 cmake 代码时获取"ld: symbol(s) not found for architecture x86_64"
- 操作系统字距错误: "ld: symbol(s) not found for architecture x86_64"
- OSX "clang++ -lboost_mpi" ' -> "ld: library not found for -lboost_mpi" 后冲泡安装提升 --with-mpi
- g++ ld: symbol(s) not found for architecture x86_64 -没有更具体的错