自行下載MinGW,安裝gcc、gdb(以後會補充完整教程)
一、g++使用
1.初始helloworld.cpp文件編寫
可在txt文件編寫,更改後綴即可。將helloworld.cpp文件放在g++.exe所在目錄下,也可配置環境變量後,在任意目錄下運行。
#include <iostream>
int main(int argc, char* argv[])
{
std::cout<<"hello world"<<std::endl;
return 0;
}
2.Preprocessing-預處理
在文件所在目錄打開命令窗口,Shift+右鍵,輸入命令:
g++ -E helloworld.cpp -o helloworld.i
3.Compilation-編譯
輸入命令:
g++ -S helloworld.i -o helloworld.s
4.Assembly-彙編
輸入命令:
g++ -C helloworld.s -o helloworld.o
5.Linking-鏈接
輸入命令:
g++ helloworld.o -o helloworld.out
報錯,失敗。
直接從.cpp->.out是可行的:
g++ helloworld.cpp -o helloworld.out
bug回頭再補充
二、gdb使用