第一次使用g++

比较幸运,尝试了几次就OK了。

 

g++ -c file_1.cpp

g++ -c file_2.cpp

g++ -c file_3.cpp

 

g++ -o file_4.out file_1.o file_2.o file_3.o file_4.cpp

 

 

参考文献:http://homepages.gac.edu/~mc38/2001J/documentation/g++.html

Running the compiler

You can use  g++ both to compile programs into object modules and to link these object modules together into a single program. It looks at the names of the files you give it to determine what language they are in and what to do with them. Files of the form  name.cc (or  name.cpp) are assumed to be C++ files and files matching  name.o are assumed to be object (i.e., machine-language) files. To translate a C++ source file,  file.cc, into a corresponding object file,  file.o, use the  g++ command:
  g++ -c compile-options file.cc
To link one or more object files,  file1.ofile2.o, ..., to produced from C++ files into a single executable file called  prog, use the following command:
  g++ -o prog link-options file1.o file2.o ... other-libraries
(The  options and  libraries clauses are described below.)

You can bunch these two steps---compilation and linking---into one with the following command.

  g++ -o prog compile-and-link-options file1.cc file2.cc ... other-libraries
After linking has produced an executable file called prog, it becomes, in effect, a new Unix command, which you can run with
  ./prog arguments

where arguments denotes any command-line arguments to the program

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值