9

I am trying to compile my program but it wouldn't link at all. I have specified the path to the boost lib files and the linker still complain. Here's the linking error I got:

1>Edproj.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::detail::thread_data_base::~thread_data_base(void)" (??1thread_data_base@detail@boost@@UAE@XZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z)
1>Edproj.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach@thread@boost@@QAEXXZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::join(void)" (?join@thread@boost@@QAEXXZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::thread::start_thread(void)" (?start_thread@thread@boost@@AAEXXZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "bool __cdecl boost::this_thread::interruptible_wait(void *,struct boost::detail::timeout)" (?interruptible_wait@this_thread@boost@@YA_NPAXUtimeout@detail@2@@Z)

BOOST_LIB_DIAGNOSTIC returns

1>  Linking to lib file: libboost_thread-vc100-mt-s-1_52.lib
1>  Linking to lib file: libboost_date_time-vc100-mt-s-1_52.lib
1>  Linking to lib file: libboost_system-vc100-mt-s-1_52.lib
1>  Linking to lib file: libboost_chrono-vc100-mt-s-1_52.lib

More info:

I am running a 64-bit Windows 8 Pro and I compiled boost with the following option

bjam --build-type=complete --toolset=msvc10.0 address-model=64 architecture=x86 variant=debug,release threading=multi link=static runtime-link=static

Can someone tell me what is wrong?

Update:

After changing to boost 1.51 it got rid 7 out of 8 of those linker errors but this one is still persistent

error LNK2001: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z)

I don't get what is going on here. This one is from boostpro 32 bit installer. It couldn't have something to do with my source file right?

Update :

Ok I have solved this problem for boost 1.51. Turns out in the Property Pages >> C/C++ >> Code Generation >> Enable C++ Exceptions was turn off for me.

OK. I will attempt to see if the same settings solve the problem for boost 1.52. Will update later.

Xavier R X Tan
  • 177
  • 1
  • 7

4 Answers4

1

I had the same problem before: I build boost lib with default parameters which run bootstrap.bat directly.

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

you can recompile boost lib with this bat, save these to 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 libs
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/

Protoss
  • 512
  • 7
  • 27
0

Be sure to add the right directories into the linker properties.

Read this post to further details Boost linker error: Unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_system_category(void)"

Also you've got to add this path into Linker addition directories:

$(BOOST_ROOT)\bin.v2\libs\thread\build\msvc-xx.0\release\address-model-64\link-static\threading-multi

where xx is your visual studio version

Community
  • 1
  • 1
Nicola Pezzotti
  • 2,317
  • 1
  • 16
  • 26
  • Hi, I stumbled upon that post before I post my question. Have done the stuff stated there but still no luck. – Xavier R X Tan Feb 03 '13 at 17:41
  • Can you post here your Linker addition directories? – Nicola Pezzotti Feb 03 '13 at 17:46
  • $(BOOST)stage\lib\;$(LibraryPath) BOOST is C:\Dev\boost_1_52_0\ – Xavier R X Tan Feb 03 '13 at 17:57
  • Another tips. If you are using Visual Studio please note that you must close it before it can read new enviroment varibles. For example in Visual studio 2005 you've got to close ALL the instances of VS2005. – Nicola Pezzotti Feb 03 '13 at 18:49
  • yeah I am aware of that actually. So every time I change my environment var. I will restart my VS to factor in the change. – Xavier R X Tan Feb 03 '13 at 19:02
  • Search on your disk for the .lib and add the containing directory directly into linker additional directories. I'm quite sure that a similar setup is good for me at work. Tomorrow I'll check it for you – Nicola Pezzotti Feb 03 '13 at 19:34
  • You've got to add this path into Linker addition directories: $(BOOST_ROOT)\bin.v2\libs\thread\build\msvc-10.0\release\address-model-64\link-static\threading-multi – Nicola Pezzotti Feb 04 '13 at 16:56
0

Thank looks to me like its no auto linking correctly.

Include path is boost152/ only
Library path is boost152/stage/lib
Andrew
  • 1,764
  • 3
  • 24
  • 38
  • Hmm... I went and did a counter check. I have set my environment variables as such: '$(BOOST) = %DEV%\boost_1_52_0\' where '%DEV% is C:\Dev\' and in the VC++ directory under property I had the following: 'Include : $(BOOST)' 'Library : $(BOOST)stage\lib\' – Xavier R X Tan Feb 03 '13 at 17:47
0

These two defines below were messing up with my linker, throwing one beautiful "LNK2001: unresolved external symbol" error. Do you have then somewhere in your code?

//#define BOOST_FILESYSTEM_NO_DEPRECATED
//#define BOOST_FILESYSTEM_NO_LIB
agodinhost
  • 381
  • 4
  • 16