linux軟體編譯安裝:make與configure

來源:互聯網
上載者:User

linux軟體編譯安裝:make與configure
1. 什麼是make和configure
make命令主要是用來簡化編譯過程。 make執行時,會在目前的目錄下搜尋 Makefile( or makefile) 檔案, 而Makefile裡面記錄了源碼如何編譯的詳細資料。 make會自動判斷源碼是否經過了變動了而自動更新執行檔案。
軟體開發商通常都會寫一個檢測使用者作業環境的程式,就是configure 或 config, 運行檢測完畢後會主動建 Makefile 檔案。
2. make命令好處
簡化編譯時間所需要執行的命令。編譯完成後,如果修改了某個源碼檔案,則 make 只會針對被修改的檔案進行編譯,其他的目標檔案不會被改變。重新編譯只會更新(update)操作,
3. Makefile文法
文法: 目標(target): 目標檔案1 目標檔案2 gcc -o 欲建立的可執行檔 目標檔案1 目標檔案2

[gang@www]$ vim Makefilehello: hello.o thank_you.o     gcc -o hello hello.o thank_you.o clean:    rm -f hello hello.o thank_you.o
clean刪除目標檔案
 [gang@www]$ make cleanrm -f hello hello.o thank_you.o [gang@www]$ makecc    -c -o hello.o hello.ccc    -c -o thank_you.o thank_you.cgcc -o hello hello.o thank_you.o  [gang@www]$ ./hello Hello World. Thank you.

makefile可以使用變數
[gang@www]$ vim MakefileOBJS = hello.o thank_you.oCFLAGS = -Wallhello: ${OBJS}    gcc -o hello ${OBJS}clean:    rm -f hello ${OBJS}
變數賦值 = 兩邊有空格, $@ : 代表當前的目標 gcc -o $@ ${OBJS}
4. 安裝基本步驟
1. ./configure 建立Makefile 檔案 2. make clean 刪除目標檔案, 3. make 根據 Makefile 進行編譯。 產生可執行檔, 可執行檔放在目前的目錄, 尚未被安裝到預定安裝目錄中。 4. make install 會根據Makefile 中的 install 選項, 將上一步編譯完的資料安裝到預設目錄中。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.