使用仅标头库时,会增加链接器错误

问题描述 投票:2回答:2

我将Boost 1.53.0的以下组件与C ++ 11库结合使用...

  • 提高:: signals2 :: scoped_connection
  • 提高:: signals2 ::信号
  • 提高:: signals2 ::连接
  • 提高::数学::常数
  • 提高:: circular_buffer
  • 提高:: lexical_cast的

根据this answer,我不需要链接库来使用Boost的这些部分。根据this answer,signals2也应该只是标题。但是,我仍然收到链接器错误...

Undefined symbols for architecture i386:
  "boost::system::system_category()", referenced from:
  ___cxx_global_var_init2 in Main.o
  ...
  "boost::system::generic_category()", referenced from:
  ___cxx_global_var_init in Main.o
  ___cxx_global_var_init1 in Main.o
  ...

为什么?

c++ boost c++11 header linker-errors
2个回答
2
投票

Boost.Signals2确实只是标题,但是Boost.System is not。您必须确保您对该库没有任何依赖性。如果它在你自己的代码中,你必须构建Boost.System并链接它。如果它是从任何一个只有头的Boost库中调用的,那就是file a bug report


2
投票

问题是虚假的

#include <boost/thread/mutex.hpp>

不小心遗留在文件中间。

© www.soinside.com 2019 - 2024. All rights reserved.