简体   繁体   中英

Linker Error When Using Boost.asio With MingW on windows 7

I tried to compile a very basic example found on the boost.asio example but I'm getting linker error's. This is the complete command line I'm using:

mingw32-c++.exe -L..\..\Important\docs\c++\boost\boost_1_48_0\stage\lib -L..\..\Important\docs\c++\boost\boost_1_48_0\stage\lib  -o bin\Debug\CPP_WITHOUT_FEAR_1st_APP.exe obj\Debug\main.o obj\Debug\prog_2.o obj\Debug\timer.o obj\Debug\convert.o   -lwsock32 ..\..\Important\docs\c++\boost\boost_1_48_0\stage\lib\libboost_system-mgw45-mt-1_48.a

The Errors I'm getting:

..\..\Important\docs\c++\boost\boost_1_48_0\stage\lib\libboost_system-mgw45-mt-1_48.a(error_code.o):error_code.cpp:(.text+0x148): undefined reference to `_Unwind_Resume'
..\..\Important\docs\c++\boost\boost_1_48_0\stage\lib\libboost_system-mgw45-mt-1_48.a(error_code.o):error_code.cpp:(.text+0x16c4): undefined reference to `_Unwind_Resume'
..\..\Important\docs\c++\boost\boost_1_48_0\stage\lib\libboost_system-mgw45-mt-1_48.a(error_code.o):error_code.cpp:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'

Tried to figure out what's wrong but I was unable to find the answer any where. Thanks, Sree

Are you trying to link object files compiled in gcc with your program compiled in g++ ?

`undefined reference to `__gxx_personality_v0'` 

is normally related to specifying gcc as the compiler when you meant to specify g++

If this isn't the case are you trying to link object files compiled with SJLJ (setjmp/longjmp) using a DW2 (Dwarf-2) compiler or vice versa ?

Eg Were your program's object files compiled by mingw (version 3.4.5 is SJLJ) and boost compiled by gcc (version 4.4+ is DW2) ?

If this was the case, then ensure that your compiler and the libraries you are linking to were compiled with the same compiler, that has either SJLJ exception handling or DW2 exception handling.

The minGW 4.40 beta on their website has DW2 by default now, and assuming that boost was compiled with DW2, that should then compile and link cleanly.

As for what SJLJ and DW2 are they are methods of exception handling. SJLJ uses setjmp and longjump, whilst DW2 uses DWARF-2 (or DWARF-3) debugging information. SJLJ is slower but DW2 requires more space, leading to large binaries.

For more information about exception handling see here

For how DW2 works see here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM