1

While compiling a DLL in Visual Studio 2013 I include some boost (1.58) header files. One is <boost/system/error_code.hpp>. As it is known this will require to link to a boost lib, by default. However, I want to use the header only variant and not handle yet another library. For that I figured out how to make it work on Linux + Mac. However, I cannot get this to work on Windows. The linker always wants that additional library (libboost_system-vc120-mt-gd-1_58.lib)

What's the trick in Visual Studio to avoid linking to that lib?

Community
  • 1
  • 1
Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
  • Perhaps one of the other boost libraries you are linking wasn't compiled with `-DBOOST_ERROR_CODE_HEADER_ONLY`? – user657267 Jul 08 '15 at 09:59
  • I do not link to any boost library. This is the first one. – Mike Lischke Jul 08 '15 at 10:04
  • I can't replicate this with GCC, I just tried building a boost_filesystem dll with a test app, as long as `-DBOOST_ERROR_CODE_HEADER_ONLY` is specified for both there's no need to link boost_system. – user657267 Jul 08 '15 at 10:13

1 Answers1

3

Ok, I found it myself. This is not mentioned anywhere in questions about boost libs including on Windows. But if you search for disabling boost auto linking (which is actually the culprit including the libs) you will find the solution: define BOOST_ALL_NO_LIB at project level (in addition to the header only flag mentioned in the other question).

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181