0

I have a program which I would like compile using cl.exe on the command-line. This program depends on some boost libraries which I fail to link to.

The error I'm getting is:

cl /Fosamples\proxy\proxy.obj /c samples\proxy\proxy.cpp /TP /O2 /EHsc 
  /DBOOST_ALL_NO_LIB /DBOOST_THREAD_USE_LIB /DBOOST_SYSTEM_USE_LIB 
  /DBOOST_USE_WINDOWS_H /DTAP_ID=\"tap0901\" /D_WIN32_WINNT=0x0501 /MD /nologo 
  /Isamples\proxy /Iinclude proxy.cpp
link /nologo /MD /OUT:samples\proxy\proxy.exe /LIBPATH:samples\proxy
  /LIBPATH:lib asiotap.lib libboost_system-vc100-mt-1_47.lib
  libboost_thread-vc100-mt-1_47.lib ws2_32.lib gdi32.lib iphlpapi.lib
  advapi32.lib samples\proxy\proxy.obj
LINK : warning LNK4044: unrecognized option '/MD'; ignored 
  asiotap.lib(bootp_builder.obj) : error LNK2001: unresolved external
  symbol "class boost::system::error_category const & __cdecl 
  boost::system::system_category(void)"
  (?system_category@system@boost@@YAAEBVerror_category@12@XZ)

I compiled Boost, using the following command-line, from the x64 MSVC command prompt:

.\b2.exe install toolset=msvc --prefix=C:\Boost-VC-x64

If I look inside libboost_system-vc100-mt-1_47.lib I can see that:

?system_category@system@boost@@YAABVerror_category@12@XZ

Is exported. But If you look closely it differs a bit from the one in my compilation errors:

?system_category@system@boost@@YAAEBVerror_category@12@XZ // The symbol I miss
?system_category@system@boost@@YAABVerror_category@12@XZ  // The exported symbol

I guess I should either change Boost or my compilation options but fail to figure what to change exactly. Any clue ?

Thank you very much.

ereOn
  • 53,676
  • 39
  • 161
  • 238
  • 1
    Use the undname.exe utility to demangle names. The extra letter is __ptr64. Sounds to me you're trying to link to a 32-bit build of boost. Not sure why the linker isn't yelling louder about that, it normally does. – Hans Passant Oct 01 '11 at 15:14
  • @HansPassant Thank you very much. That was it, indeed. Didn't know about `undname.exe`: definitely useful :) – ereOn Oct 02 '11 at 13:00
  • Possible duplicate of [Trying to link Boost 1.52 thread](http://stackoverflow.com/questions/14674374/trying-to-link-boost-1-52-thread) – Protoss May 29 '16 at 06:48

1 Answers1

0

After some investigations, I realized that I compiled Boost for a x86 platform where I was linking with a x64 binary.

I thought that compiling Boost inside a Visual Studio x64 command prompt was enough but you actually have to specify:

.\b2.exe install toolset=msvc address-model=64 --prefix=C:\Boost-VC-x64

To make it work.

ereOn
  • 53,676
  • 39
  • 161
  • 238