"_ Gxx_personality_v0" appears in the c program compiled by gcc"

Source: Internet
Author: User
"_ Gxx_personality_v0" appears in the c program compiled by gcc -- Linux general technology-Linux programming and kernel information. For details, see the following. (1) Note: it is a c program.
Unfortunately, it took me an hour or two to find out why I encountered this problem. Compiling c code in VC or even TC2.0 has no problem. When it comes to gcc, this error is really depressing.

I checked it online and did not solve the problem. Only the error message "_ gxx_personality_v0" indicates an error occurred when compiling c ++ code with gcc. Most of the solutions provided on the Internet are to add the "-lstdc ++" parameter during compilation, that is, to use gcc as g ++. But this is obviously not what I want. The target file compiled with the "-lstdc ++" parameter is almost twice as fat. There is no reason that a c program is compiled based on c ++. I checked carefully that there is no c ++ code in the program, and the c ++ code is probably not compatible with TC2.0. As a result, it is hopeless to start to doubt the compiler again ...... Finally, I found the answer in an article on the blog oliliango.cublog.cn: "compilation errors such as _ gxx_personality_v0 are caused by the mismatch between the source code file suffix and the code syntax, for example, if a file using the C syntax selects a suffix such as cpp (or <大写c> Such suffix )". Check that, because the source code has been edited using TC, the file name is converted to uppercase, so it is faulty.

(2)

1. Linux Develop Notes
To compile the c ++ program, add-lstdc ++ sample: gcc-lstdc ++-o test. c. Otherwise, the error "undefinedreference to '_ gxx_personality_v0'" will be reported.

2. Alas, use the gcc command to compile the C program, and use the g ++ command to compile the C ++ program.
G ++ and gcc are essentially the same. In essence, gcc is used. All the c ++ programs in our lab are compiled with gcc, and the general program is enough with gcc. For C ++ programs, gcc or g ++ can be used during compilation. However, it is best to use g ++ for connection, because g ++ will automatically connect to the C ++ standard library. You can also use gcc to connect to the C ++ program, however, you must manually connect to the C ++ standard library. Otherwise, an error such as undefined reference to '_ gxx_personality_v \ 0' may occur.

It can be seen that lstdc ++ corresponds to the Standard C ++ library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.