learnvst
learnvst

Reputation: 16193

Boost linker errors when using header-only libraries

I am using the following components of Boost 1.53.0 in conjunction with C++11 libraries...

According to this answer, I do not need to link against libraries to use these parts of Boost. According to this answer, signals2 should be header-only also. However, I still receive linker errors...

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
  ...

Why?

Upvotes: 2

Views: 1051

Answers (2)

learnvst
learnvst

Reputation: 16193

The problem was a spurious

#include <boost/thread/mutex.hpp>

accidentally left in the middle of a file.

Upvotes: 2

TemplateRex
TemplateRex

Reputation: 70546

Boost.Signals2 is indeed header-only, but Boost.System is not. You have to make sure that you don't have any dependency on that library. If it's in your own code, you have to build Boost.System and link against it. If it's called from any header-only Boost library, file a bug report.

Upvotes: 2

Related Questions