Boost linker error: Unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_system_category(void)"

45,219

Solution 1

I solved the problem. I had built 32-bit libraries when I had intended to build 64-bit libraries. I fixed up my build statement, and built 64-bit libraries, and now it works.

Here is my bjam command line:

C:\Program Files (x86)\boost\boost_1_38>bjam --build-dir=c:\boost --build-type=complete --toolset=msvc-9.0 address-model=64 architecture=x86 --with-system

Solution 2

#include <boost/system/config.hpp>

In my case, BOOST_LIB_DIAGNOSTIC did not show system being automatically linked in. I resolved this by simply including boost/system/config.hpp.

Solution 3

You need to link in the boost_system library

Solution 4

If you use boost::system in your project, you should use and appoint the x86 or x64 version of boost::system lib.

You can recompile Boost library with the following batch file. Save these to the Boost root folder and run it in CMD Windows (don't double click!):

call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86


cd boost_1_60_0
call bootstrap.bat

rem Most libraries can be static libraries
b2 -j8 toolset=msvc-14.0 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64
b2 -j8 toolset=msvc-14.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32

pause

For more details, you can see this article: https://studiofreya.com/2015/12/19/how-to-build-boost-1-60-with-visual-studio-2015/

Solution 5

I had the same problem. I tried all described above, but nothing helps. The solution was simple: first I worked with an empty project and there I had linker error LNK2019. But when I created new default Win32 console application with stdafx.h, targetver.h and stdafx.cpp files everything worked. May be it will be useful for somebody, I spend two days for this

Share:
45,219
Alex Black
Author by

Alex Black

Alex Black's blog Alex Black on LinkedIn

Updated on September 30, 2020

Comments

  • Alex Black
    Alex Black over 3 years

    I'm just getting started with Boost for the first time, details:

    1. I'm using Visual Studio 2008 SP1
    2. I'm doing an x64 Build
    3. I'm using boost::asio only (and any dependencies it has)

    My code now compiles, and I pointed my project at the boost libraries (after having built x64 libs) and got past simple issues, now I am facing a linker error:

    2>BaseWebServer.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_system_category(void)" (?get_system_category@system@boost@@YAAEBVerror_category@12@XZ)
    2>BaseWebServer.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_generic_category(void)" (?get_generic_category@system@boost@@YAAEBVerror_category@12@XZ)
    

    any ideas?


    I added this define: #define BOOST_LIB_DIAGNOSTIC

    And now in my output I see this:

    1>Linking to lib file: libboost_system-vc90-mt-1_38.lib
    1>Linking to lib file: libboost_date_time-vc90-mt-1_38.lib
    1>Linking to lib file: libboost_regex-vc90-mt-1_38.lib
    

    which seems to indicate it is infact linking in the system lib.