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

前端 未结 10 2248
执念已碎
执念已碎 2020-12-01 15:32

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:
相关标签:
10条回答
  • 2020-12-01 16:15

    I came to the question via searching for the linker error plus CMAKE, so I'm adding this comment here in case anyone else finds this question the same way.

    It turns out that the linker error in my case was due to an errant:

        add_definitions(-DBOOST_ALL_DYN_LINK)
    

    in the CMakeLists.txt, which is fine for Unix, but not Windows in my case. The solution is not use that define on Windows.

    0 讨论(0)
  • 2020-12-01 16:19
    #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.

    0 讨论(0)
  • 2020-12-01 16:19

    None of the methods worked for me given before in this thread. Then I checked the files inside boost system folder and tried below #define

    #define BOOST_ERROR_CODE_HEADER_ONLY

    The linking error is solved after using this.

    0 讨论(0)
  • 2020-12-01 16:27

    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/

    0 讨论(0)
  • 2020-12-01 16:28

    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

    0 讨论(0)
  • 2020-12-01 16:29

    In my case, I resolved this by moving the boost include dir from

    Project -> Properties-> VC++ Directories -> Include Directories
    

    to

    Project -> Properties-> C/C++ -> General -> Additional Include Directories
    

    , and moving the boost lib dir from

    Project -> Properties-> VC++ Directories -> Library Directories
    

    to

    Project -> Properties-> Linker -> General -> Additional Library Directories
    

    Maybe the error is caused by link order.

    0 讨论(0)
提交回复
热议问题