I've been getting this undefined symbol building with this command line:
$ gcc test.cpp
Undefined symbols:
"___gxx_personality_v0", referenced from:
etc...
test.cpp is simple and should build fine. What is the deal?
I've been getting this undefined symbol building with this command line:
$ gcc test.cpp
Undefined symbols:
"___gxx_personality_v0", referenced from:
etc...
test.cpp is simple and should build fine. What is the deal?
The deal is that you're tired and dumb. :)
Use
g++ test.cpp
instead, since this is c++ code.
the extension .cpp causes gcc to compile your file as a c++ file.
According to this page the extension does matter: http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Overall-Options.html#index-file-name-suffix-71
Try compiling the same file but with the .c
extension (or alternatively explicitly specify the language with -x c
). If you run nm test.o
(where test.o is the object file resulting from running gcc -x c -c test.cpp -o test.o
) you'll notice that ___gxx_personality_v0
is not listed as a symbol whereas if you run the same command on an object file generated with gcc -c test.cpp -o test.o
the ___gxx_personality_v0
is present.