Home > Backend Development > C++ > Why Do I Get the \'Undefined Symbol \'___gxx_personality_v0\'\' Error When Compiling C Code with GCC?

Why Do I Get the \'Undefined Symbol \'___gxx_personality_v0\'\' Error When Compiling C Code with GCC?

Linda Hamilton
Release: 2024-11-23 13:09:11
Original
669 people have browsed it

Why Do I Get the

Undefined Symbol "___gxx_personality_v0" in GCC Builds

When compiling C code with the command line gcc test.cpp, developers may encounter the error:

Undefined symbols:
  "___gxx_personality_v0", referenced from:
  etc...
Copy after login

This error occurs because gcc is intended for compiling C code. To build C code, use the C compiler g instead:

g++ test.cpp
Copy after login

Alternatively, if gcc must be used, add the -lstdc flag to the command line:

gcc test.cpp -lstdc++
Copy after login

This flag links the Standard C Library, which contains the necessary symbols.

Running md5 on the resulting executables (.a.out) from both g and gcc with -lstdc yields identical output, indicating that they are equivalent.

Therefore, using g is generally recommended for compiling C code for simplicity and compatibility.

The above is the detailed content of Why Do I Get the \'Undefined Symbol \'___gxx_personality_v0\'\' Error When Compiling C Code with GCC?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template