1
votes

I am attempting to update my code and libraries for use in Visual Studio 2013 but I am having problems with Boost 1.57.0. For whatever reason MSVC 12.0 refuses to properly compile program_options due to two linker errors (either building a project with program_options being used or attempt to build the library itself).

I have tried building the library but these linker errors were preventing it. I also get these errors using the pre-built SourceForge binaries located here: http://sourceforge.net/projects/boost/files/boost-binaries/1.57.0/

These are the linker errors I am getting:

error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > boost::program_options::arg" (?arg@program_options@boost@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

error LNK2001: unresolved external symbol "public: static unsigned int const boost::program_options::options_description::m_default_line_length" (?m_default_line_length@options_description@program_options@boost@@2IB)

I have been Googling this problem for the last three hours but I have found no solutions to this problem (several previously posted solutions for very old versions of Boost have not worked for me).

Some other information:

library name: libboost_program_options-vc120-mt-1_57 RT Library: Multi-threaded DLL (/MD)

If you need any other info let me know and I will add it to the o. post.

1
Are you linking with boost options (you have to) ? How did you configure your project to do so ?quantdev
@quantdev Not sure why it was not working earlier. I had my boost files (everything) in my project folder. When I moved them back out to how I had my previous boost install setup and re-did the include/library directory settings it works now.Geowil

1 Answers

3
votes

You have to link to the static library. Try linking to boost_program_options-vc100-mt-sgd-1_47.lib instead of libboost_program_options-vc120-mt-gd-1_57.lib.

The s indicates the static version of the library. You can check Boost Library Namingfor more details about the naming conventions.

To fix the multiple definition linker errors, change the Visual Studio Runtime Library option in Configuration Properties >> C/C++ >> Code Generation >> Runtime Library from Multi-threaded Debug DLL (/MDd) to Multi-threaded Debug (/MTd).