顯示具有 Makefile 標籤的文章。 顯示所有文章
顯示具有 Makefile 標籤的文章。 顯示所有文章

2026年1月17日 星期六

Windows下執行makefile - Mingw-w64

1. 至Mingw-w64的網站下載執行檔,下載網址: https://www.mingw-w64.org/downloads/

2. 點選MinGW-W64-builds欄位。


3. 點選MinGW-W64-builds欄位下的GitHub。


4. 選擇下載版本,我這裡選擇"x86_64-15.2.0-release-posix-seh-ucrt-rt_v13-rev0"。

x86_64: 代表64-bit x86架構

15.2.0: GCC 15版本

release: 正式發布版本

posix: 使用POSIX threads API,在Windows上透過MinGW-W64實作,適合Linux/Windows跨平台程式

seh: Structured Exception Handling,Windows原生例外處理機制,僅支援x86_64,效能好

ucrt: 使用Universal C Runtime,微軟現代CRT(Windows 10+內建),與MSVC相容性高。

5. 下載至"C:\Program Files"並解壓縮。

6. 至"C:\Program Files\x86_64-15.2.0-release-posix-seh-ucrt-rt_v13-rev0\mingw64\bin"路徑下,點選"mingw32-make"。

7. 修改名稱為"make"。

8. 至"系統內容" > "環境變數"。

9. 點選"系統變數" > "Path" 後按"編輯"。

10. 按下"新增",增加"C:\Program Files\x86_64-15.2.0-release-posix-seh-ucrt-rt_v13-rev0\mingw64\bin"路徑後按"確定"。

11. 在搜尋欄位中輸入"cmd",開啟"命令提示字元"。

12. 輸入"make -v",顯示GNU Make的版本就表示設定成功。


**注意: 上述步驟不包含C語言所需要的函示庫,如要包含C語言函示庫+MinGW-W64請至"WinLibs.com"網頁下載。

13. 至下載網址:"https://winlibs.com/"

14. 點選下載連結。

15. 設定流程與步驟5相同。

2013年10月31日 星期四

簡易Makefile撰寫

Makefile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#It is a main.c

main: main.o
<Tab>gcc main.o -o main
main.o: main.c
<Tab>gcc main.c -c
clean:
<Tab>rm -rf main.o
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


main.c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stdlib.h>

int main(void)
{
    printf("HelloWorld\n");
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

最後在終端機輸入"make main",就會編譯出執行檔.