MSYS模仿了Linux下的編譯環(huán)境,但與Windows上IDE比起來,不足的是需要自己寫Makefile。因此也可以搭建類似Linux的automake環(huán)境來生成Makefile。
折騰了2個多小時,才把環(huán)境搞定。步驟如下:
1 下載與安裝
下載如下工具或組件:
autoconf,automake,m4,libtool,perl,crypt。
下載地址:
http://sourceforge.net/projects/mingw/files/MSYS/ 其中autoconf,automake是主要使用工具;m4,libtool是必要工具;perl是支撐工具;crypt是支撐庫。libtool和crypt以庫的形式下載。
下載好的文件如下:autoconf-2.67-1-msys-1.0.15-bin.tar.lzma,automake-1.11.1-1-msys-1.0.13-bin.tar.lzma,m4-1.4.14-1-msys-1.0.13-bin.tar.lzma,libltdl-2.4-1-msys-1.0.15-dll-7.tar.lzma,perl-5.6.1_2-2-msys-1.0.13-bin.tar.lzma,libcrypt-1.1_1-3-msys-1.0.13-dll-0.tar.lzma。解壓后拷貝到C:\msys\1.0下,覆蓋即可。
2 automake使用
1)運行autoscan命令,產(chǎn)生configure.scan文件;
2)將configure.scan 文件重命名為configure.in,并修改configure.in文件;
3)運行aclocal命令,產(chǎn)生aclocal.m4文件;
4)運行autoconf命令,產(chǎn)生configure文件;
5)新建Makefile.am文件,新建NEWS、 README、 ChangeLog 、AUTHORS文件;
6)修改Makefile.am,并運行automake -a命令;(automake --add-missing)
7)運行./confiugre腳本。
8)至此,Makefile已生產(chǎn),然后執(zhí)行make編譯即可。
其中configure.in的修改,Makefile.am的修改。可參考其他網(wǎng)上資料。
參考:
http://www.ibm.com/developerworks/cn/linux/l-makefile/ (復(fù)雜例子)
http://tech.sina.com.cn/s/2004-10-19/1115443045.shtml (簡單例子)
FAQ
1 問題:/bin/install: Permission denied
解決方法:從
再次出現(xiàn)該錯誤。繼續(xù):在控制面板 -- 用戶賬戶和家庭安全 -- 用戶賬戶中,打開更改用戶賬戶控制設(shè)置,將級別調(diào)至最低。需要重啟。至此,還未測試是否有效。
參考:http://lists-archives.org/mingw-msys/00059-problem-with-chmod.html 2 問題:執(zhí)行automake -a后出現(xiàn):required file './ltmain.sh' not found
解決方法:在執(zhí)行aclocal和automake -a前執(zhí)行
libtoolize命令,來產(chǎn)生ltmain.sh到當(dāng)前目錄。
參考:
http://blog.chinaunix.net/u2/84449/showart_2087602.html3 執(zhí)行automake -a,出現(xiàn):Makefile.am:29: `%'-style pattern rules are a GNU make extension
解決:執(zhí)行
automake -Wno-portability
參考:http://bugs.mysql.com/bug.php?id=30708