Link Error "Undefined Reference to '_Gxx_Personality_V0'" and G++

Link error undefined reference to `__gxx_personality_v0' and g++

If g++ still gives error Try using:

g++ file.c -lstdc++

Look at this post: What is __gxx_personality_v0 for?

Make sure -lstdc++ is at the end of the command. If you place it at the beginning (i.e. before file.c), you still can get this same error.

Undefined Symbol ___gxx_personality_v0 on link

Use

g++ test.cpp

instead, since this is c++ code.


Or, if you really want to use gcc, add -lstdc++ to the command line, like so:

gcc test.cpp -lstdc++

Running md5 against the a.out produced under each scenario shows that it's the same output.

But, yeah, g++ probably makes your world a simpler place.

Undefined reference to _Unwind_Resume and __gxx_personality_v0

I finally fixed this by importing into Code::Blocks the source code of JsonCpp and creating the library myself. I am still baffled though as to why the library created with Scons didn't work, since it was using the same compiler that Code::Blocks uses, but at the same time it was not ( or the error wouldn't have been there ).

Mysterious linker error undefined reference to `__gxx_personality_v0' using clang in cygwin

Found this solution:

https://cygwin.com/ml/cygwin/2015-06/msg00294.html

Basically just add -fno-exceptions on the command line when you compile for example clang++ helloworld.cpp -std=c++11 -fno-exceptions

What is __gxx_personality_v0 for?

It is used in the stack unwiding tables, which you can see for instance in the assembly output of my answer to another question. As mentioned on that answer, its use is defined by the Itanium C++ ABI, where it is called the Personality Routine.

The reason it "works" by defining it as a global NULL void pointer is probably because nothing is throwing an exception. When something tries to throw an exception, then you will see it misbehave.

Of course, if nothing is using exceptions, you can disable them with -fno-exceptions (and if nothing is using RTTI, you can also add -fno-rtti). If you are using them, you have to (as other answers already noted) link with g++ instead of gcc, which will add -lstdc++ for you.

undefined reference to `__gxx_personality_v0' with gcc

Use either g++ - since your file is suffixed .cpp or rename the file to .c and keep the command line as is. Tested on Debian 6.0.5 with gcc 4.4.5.

undefined reference error in VScode

It looks like your main.c file is not being linked with test.c.
I have been able to reproduce the exact same error message using the following compilation commands:

$ gcc main.c
/tmp/ccVqEXL5.o: In function `main':
main.c:(.text+0x8): undefined reference to `a'
main.c:(.text+0x38): undefined reference to `aa'
main.c:(.text+0x51): undefined reference to `bb'
main.c:(.text+0x69): undefined reference to `function'
collect2: error: ld returned 1 exit status

To fix this, simply add your test.c file to the compilation by either doing gcc main.c test.c.



Related Topics



Leave a reply



Submit