[GCC for C ++] compilation options-ide masks the sky
Source: Internet
Author: User
Single source file to Executable
$ G ++ helloworld. cpp [-O helloworld]
Compile C ++ with GCC:
$ GCC helloworld. cpp-lstdc ++-O helloworld
_____________________________________________
Multiple source files to Executable
$ G ++ hellospeak. cpp speak. cpp-O hellospeak
_____________________________________________
Source file to object file
$ G ++-C hellospeak. cpp-O hspk1.o
$ G ++-C speak. cpp-O hspk2.o
$ G ++ heat k1.o heat k2.o-O hellospeak
-C: generate the. o file
____________________________________________
Preprocessing
$ G ++-e helloworld. cpp [-O helloworld. II]
-E: Only pre-processing files are generated.
____________________________________________
Generating assembly language
$ G ++-s helloworld. cpp
-S: generate only assembly files
____________________________________________
Creating a static library
Generate a. o file. Ar is a file.
$ G ++-C sayhello. cpp
$ G ++-C say. cpp
$ Ar-r libsay. A sayhello. o say. o
Use static library
$ G ++ saymain. cpp libsay. A-O saymain
_____________________________________________
Creating a shared library
Generate the. o file and generate the. So file.
$ G ++-C-FPIC average. cpp
$ Gcc-shared average. O-o average. So
Or:
$ G ++-FPIC-shared average. cpp-O average. So
_______________________________________________
Libraries
The standard C ++ library is libstdc ++. A, which contains all the standard C ++ programs.
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.