windows下使用命令行编译、链接C++源文件
1.流程
.cpp-->.o-->.exe
分别为
源文件-->中间目标文件-->可执行文件
两个-->的过程分别为编译、链接
p.s.多个 .o 文件可以打包为库文件.lib文件
2.操作
文件地址为e:\a.cpp
内容为
#include <stdio.h>
using namespace std;
int main(void)
{
char c[10];
scanf("%s",c,9);
printf("%s", c);
return 0;
}
接下来打开cmd开始操作
cd\
e:
g++ a.cpp //生成a.exe
a.exe //执行
此外可以进行别的操作
g++ -c a.cpp //生成a.o文件
g++ -o text a.cpp //改名为text.exe

浙公网安备 33010602011771号