Undefined link to _unwind_resume and __gxx_personality_v0

I am trying to use the JsonCpp library. I am on Windows using MinGW and CodeBlocks.

When I include any of the json headers, my linker explodes and throws these two errors. I began to look around, and I found these two other questions that basically describe my problem:

problem with g ++ and "undefined reference to __gxx_personality_v0 '"

What is __gxx_personality_v0 for?

And if I declare two missing variables as void pointers, as shown below, the problem disappears:

void * __gxx_personality_v0=0; void * _Unwind_Resume =0; 

However, I do not understand why this error occurs. CodeBlocks is configured in such a way that the migw32-g ++ file is used for cpp files, and the addition of the -lstdC ++ option does not fix the problem. And the -fno-exception option (I want exceptions, mind you, I just tried).

I also include the boost library in the same file and this does not cause any problems.

EDIT:

The error output is exactly what I said in my title: I get a total of 22 undefined references to _Unwind_Resume and __gxx_personality_v0 during linking. My code is:

 #include <boost/algorithm/string.hpp> #include <include/json/value.h> //void * __gxx_personality_v0=0; //void * _Unwind_Resume =0; int main () { std::string str1("Hello world!"); boost::to_upper(str1); Json::Value k; return 0; } 

The error only occurs when I enable / use the JsonCPP library. Exposing commented lines fixes the problem.

Command line output:

 mingw32-g++.exe -Wall -fexceptions -g -DSFML_DYNAMIC -IC:\Users\Svalorzen\Documents\Projects\boost_1_49 -IC:\Users\Svalorzen\Documents\Projects\jsoncpp-src-0.5.0 -IC:\Users\Svalorzen\Documents\Projects\SFML-1.6\include -IC:\Users\Svalorzen\Documents\Projects\hge181\include -c C:\Users\Svalorzen\Documents\Projects\test\main.cpp -o obj\Debug\main.o mingw32-g++.exe -LC:\Users\Svalorzen\Documents\Projects\jsoncpp-src-0.5.0 -LC:\Users\Svalorzen\Documents\Projects\SFML-1.6\lib -LC:\Users\Svalorzen\Documents\Projects\hge181\lib -o bin\Debug\test.exe obj\Debug\main.o -fno-exceptions -lsfml-graphics -lsfml-window -lsfml-system C:\Users\Svalorzen\Documents\Projects\jsoncpp-src-0.5.0\libs\mingw\libjson_mingw_libmt.a C:\Users\Svalorzen\Documents\Projects\hge181\lib\gcc\libhge.a C:\Users\Svalorzen\Documents\Projects\hge181\lib\gcc\libhelp.a Output size is 1.22 MB Process terminated with status 0 (0 minutes, 3 seconds) 0 errors, 0 warnings 

SECOND EDIT: I add the commands that I use to compile the library:

 g++ -o buildscons\mingw\src\lib_json\json_reader.o -c -DWIN32 -DNDEBUG -D_MT -Iinclude src\lib_json\json_reader.cpp g++ -o buildscons\mingw\src\lib_json\json_value.o -c -DWIN32 -DNDEBUG -D_MT -Iinclude src\lib_json\json_value.cpp g++ -o buildscons\mingw\src\lib_json\json_writer.o -c -DWIN32 -DNDEBUG -D_MT -Iinclude src\lib_json\json_writer.cpp ar rc buildscons\mingw\src\lib_json\libjson_mingw_libmt.a buildscons\mingw\src\lib_json\json_reader.o buildscons\mingw\src\lib_json\json_value.o buildscons\mingw\src\lib_json\json_writer.o ranlib buildscons\mingw\src\lib_json\libjson_mingw_libmt.a 
+7
source share
2 answers

I finally fixed this by importing the JsonCpp source code into Code :: Blocks and creating the library myself. I am still puzzled why the library created using Scons does not work, because it uses the same compiler as Code :: Blocks, but at the same time it was not (or the error would not be there).

0
source

For those who approach this from google (like me), the real reason for undefined references to _Unwind_Resume and __gxx_personality_v0 is "using gcc using a different method of expanding the stack than dwarf2" [a href = "https: //www.allegro. cc / forums / thread / 603070/850244 # target "> 1]

In my case, he was trying to link code compiled with GCC 4.9 up to a library compiled with GCC 4.8 or lower. The solution is to recompile the library with the same compiler with which you are building.

+24
source

All Articles