我是 C++ 的新手,我想编译我的测试程序。
我现在有 3 个文件 "main.cpp""parse.cpp""parse.h"
如何用一条命令编译它?
最佳答案
同时编译它们并将结果放入a.out
$ g++ file.cpp other.cpp
同时编译它们并将结果放入prog2
$ g++ file.cpp other.cpp -o prog2
分别编译每个,然后将它们链接到a.out
$ g++ -c file.cpp
$ g++ -c other.cpp
$ g++ file.o other.o
分别编译,然后链接到prog2
$ g++ -c file.cpp
$ g++ -c other.cpp
$ g++ file.o other.o -o prog2
关于c++ - 使用 gcc/g++ 编译器编译 c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1153101/