【问题标题】:What does "library has no symbol" mean? [duplicate]“图书馆没有符号”是什么意思? [复制]
【发布时间】:2017-05-23 01:03:21
【问题描述】:

我正在使用 CMake 构建我的项目所需的一些依赖库。它们是 Boost_system、Boost_filesystem 和 Boost_program_options。我是单独编译静态库,而不是编译整个 Boost 库。

一切正常,但我收到以下警告消息:

...
[ 67%] Building CXX object filesystem/CMakeFiles/filesystem.dir/src/utf8_codecvt_facet.cpp.o
[ 70%] Building CXX object filesystem/CMakeFiles/filesystem.dir/src/windows_file_codecvt.cpp.o
[ 74%] Linking CXX static library libfilesystem.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libfilesystem.a(windows_file_codecvt.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libfilesystem.a(windows_file_codecvt.cpp.o) has no symbols
[ 74%] Built target filesystem
[ 77%] Building CXX object CMakeFiles/canalogsmp.dir/src/Array2D.cpp.o
...

我的问题是:

  • 符号是什么?警告信息是什么意思?
  • 如何消除此警告消息?

【问题讨论】:

  • 谢谢。我要关闭它。

标签: c++ compilation cmake linker


【解决方案1】:

感谢nakiya,我找到了答案。

所以警告信息的解释是here。基本上,ranlib 没有找到任何操作代码。但就我而言,我只需要忽略这些警告。

here 提供了解决方案,也粘贴在下面。确保将标志传递给 ranlib 而不是编译器本身。

SET(CMAKE_C_ARCHIVE_FINISH   "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")

【讨论】:

  • 这里请重复解释和解决方法,而不是仅仅链接。
  • 在此处添加它,以便我对答案进行投票。如果这些链接死了,这是没用的
猜你喜欢
  • 2014-04-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-13
  • 2013-01-26
  • 1970-01-01
  • 2012-11-03
  • 2016-10-10
  • 1970-01-01
相关资源
最近更新 更多