2

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

  • boost::signals2::scoped_connection
  • boost::signals2::signal
  • boost::signals2::connection
  • boost::math::constants
  • boost::circular_buffer
  • boost::lexical_cast

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
learnvst
  • 15,455
  • 16
  • 74
  • 121
  • A quick browse of the documentation for Signals2 in Boost 1.53.0 also says that it's header only. I'm reasonably sure the others are too. However... are you sure you don't have, say, Boost.Asio in that list too? That requires linking with Boost.System for its error codes. – Kaz Dragon Jun 07 '13 at 10:08
  • 2
    You just excluded the interesting part: `referenced from: ...` from where? That part will give you the info wich lib/function calls Boost.System – Arne Mertz Jun 07 '13 at 10:12
  • @ArneMertz added some detail . . the rest is a list of other files giving the same `___cxx_global_var_init` type messages – learnvst Jun 07 '13 at 10:57
  • please give us the full compiler error, and also your full list of Boost packages. E.g. Boost.Asio also uses Boost.system if I am not mistaken – TemplateRex Jun 07 '13 at 10:58
  • Problem solved . . see Answer. Darn I feel stupid :S Thanks all – learnvst Jun 07 '13 at 11:10

2 Answers2

2

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.

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
2

The problem was a spurious

#include <boost/thread/mutex.hpp>

accidentally left in the middle of a file.

learnvst
  • 15,455
  • 16
  • 74
  • 121