日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

makefile入门

發(fā)布時(shí)間:2025/6/15 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 makefile入门 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

? ? ? ? ? ? ? ? ? linux下編程,makefile的重要性不用多說,網(wǎng)上一大堆,今天簡單的實(shí)戰(zhàn)一下。

[xxx@localhost test]$ ls makefile test1.cpp test2.cpp [xxx@localhost test]$ cat test1.cpp #include<stdio.h>int main() {printf("this is test1\n");return 0; } [xxx@localhost test]$ cat test2.cpp #include<stdio.h>int main() {printf("this is test2\n");return 0; } [xxx@localhost test]$ cat makefile all:test1 test2test1:test1.o g++ test1.o -o test1 test2:test2.og++ test2.o -o test2test1.o:test1.cppg++ -c test1.cpp -o test1.o test2.o:test2.cppg++ -c test2.cpp -o test2.oclean:rm -fr *.o [xxx@localhost test]$

執(zhí)行:

[xxx@localhost test]$ make g++ -c test1.cpp -o test1.o g++ test1.o -o test1 g++ -c test2.cpp -o test2.o g++ test2.o -o test2 [xxx@localhost test]$ ls makefile test1 test1.cpp test1.o test2 test2.cpp test2.o [xxx@localhost test]$ ./test1 this is test1 [mapan@localhost test]$ ./test2 this is test2 [xxx@localhost test]$ all作用:makefile會把第一個(gè)目標(biāo)作為默認(rèn),all可以指定多個(gè)目標(biāo)

test.o:test.cpp這表示依賴關(guān)系,標(biāo)明生成test.o需要test.cpp

[mapan@localhost test]$ make clean rm -fr *.o make clean清除所有.o文件



總結(jié)

以上是生活随笔為你收集整理的makefile入门的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。