How to compile a C + + program under Linux

Source: Internet
Author: User

Http://wenku.baidu.com/link?url=xnjP6WXTPbpGBRvkAqCxeFQDSt3yN6H_ Yhm-lutjz6wm1mu9mujbfzkzoq09v5qzbnozesfynuhqwavkvabmd5ljxumz1hw0b7z8n5n7oow

Today I compiled a sendpkt.cpp source program, using the Linux compiler command. The use of the above document in a few sentences, really very simple, very useful oh.

GCC(GNU Compiler Collection) is the most important compilation tool under Linux,gcc Not only is the function very powerful, the structure is also exceptionally flexible.

It can support various languages through different front-end modules, such as Java,Fortran,Pascal,Modula-3 and Ada

g++ is A tool in GCC that specifically compiles the C + + language.

the parameters of GCC are:( also implemented in step )

-e allows GCC to stop compiling g++-e hello.cpp-o hello.i after preprocessing ends

-C compiles hello.i to target code g++-C hello.i-o hello.o

Connect the destination file to an executable file g++ hell.o-o Hello

Can be implemented in one step g++ hello.cpp-o Hello

Second, if there are more than two source files should be compiled.

One step to achieve g++ foo1.cpp foo2.cpp-o foo

You can also implement g++-C foo1.cpp-o foo1.o

g++-C Foo2.cpp-o foo2.o

g++ FOO1.O foo2.o-o foo

How to compile a C + + program under Linux

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.