之前為了使用一個庫,都是去下載源碼,然后根據開發者提供的README手動用GCC編譯,一直不能使用Makefile感覺很蛋痛,比如最近使用的ZThread
還是怪自己以前過于依賴IDE
?
最近發現用Cygwin就可以使用諸如./configure, make這樣的命令,感覺灰常欣喜,嘗試去編譯ZThread庫(因為我發現雖然之前我用GCC手動編譯了ZThread但是在使用的過程中,ZThread總是往控制臺上打印諸多的DEBUG信息,想必是編譯選項的問題,我又不知道到哪個頭文件中去找#define DEBUG,所以就想使用make,看使用ZThread作者寫的configuration文件以及Makefile來編譯能不能解決問題)
?
剛剛下載下來Cygwin就等著上去configure+make呢,問題就來了,輸入./configure之后,等了一段時間報錯(見紅色文字):
$ ./configure checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin checking target system type... i686-pc-cygwin checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes Loading m4 macros from share checking for g++... g++ checking for C++ compiler default output file name... a.exe checking whether the C++ compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for style of include used by make... GNU checking dependency style of g++... gcc3 checking for gcc... gcc checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking dependency style of gcc... gcc3 checking how to run the C preprocessor... gcc -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking pthread.h usability... no checking pthread.h presence... no checking for pthread.h... no checking for sched_get_priority_max in -lrt... no checking for sched_yield... no checking for pthread_yield... no checking for pthread_key_create... no checking for pthread_keycreate... no checking for doxygen... no detecting for ftime() function checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for _ftime()... yes checking how to run the C++ preprocessor... g++ -E checking for ANSI C header files... (cached) yes checking errno.h usability... yes checking errno.h presence... yes checking for errno.h... yes checking for target implementation... compile-time guess checking for sigsetjmp()... no checking for _beginthreadex()... no checking for a sed that does not truncate output... /usr/bin/sed checking for ld used by gcc... d:/mingw/mingw32/bin/ld.exe checking if the linker (d:/mingw/mingw32/bin/ld.exe) is GNU ld... yes checking for d:/mingw/mingw32/bin/ld.exe option to reload object files... -r checking for BSD-compatible nm... /cygdrive/d/MinGW/bin/nm -B checking whether ln -s works... yes checking how to recognise dependent libraries... file_magic ^x86 archive import|^x86 DLL checking dlfcn.h usability... no checking dlfcn.h presence... no checking for dlfcn.h... no checking how to run the C++ preprocessor... g++ -E checking for g77... no checking for f77... no checking for xlf... no checking for frt... no checking for pgf77... no checking for fort77... no checking for fl32... no checking for af77... no checking for f90... no checking for xlf90... no checking for pgf90... no checking for epcf90... no checking for f95... no checking for fort... no checking for xlf95... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for gfortran... no checking whether we are using the GNU Fortran 77 compiler... no checking whether accepts -g... no checking the maximum length of command line arguments... 8192 checking command to parse /cygdrive/d/MinGW/bin/nm -B output from gcc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking for correct ltmain.sh version... grep: character class syntax is [[:space:]], not [:space:] no*** Gentoo sanity check failed! *** *** libtool.m4 and ltmain.sh have a version mismatch! *** *** (libtool.m4 = 1.5.10, ltmain.sh = ) ***Please run:libtoolize --copy --forceif appropriate, please contact the maintainer of this package (or your distribution) for help.
輸入:libtoolize --copy --force提示libtoolize: command not found
咋辦?搜了一下相關的問題,原來是因為安裝Cygwin的時候沒有安裝libtool
重新運行Cygwin-setup(注意,無需卸載,重新運行setup,選擇你沒有安裝的package即可),搜索libtool,勾選并安裝,問題解決
?
然后再次運行libtoolize --copy --force,又報錯:
$ libtoolize --copy --force libtoolize: putting auxiliary files in `.'. libtoolize: copying file `./ltmain.sh' libtoolize: You should add the contents of the following files to `aclocal.m4': libtoolize: `/usr/share/aclocal/libtool.m4' libtoolize: `/usr/share/aclocal/ltoptions.m4' libtoolize: `/usr/share/aclocal/ltversion.m4' libtoolize: `/usr/share/aclocal/ltsugar.m4' libtoolize: `/usr/share/aclocal/lt~obsolete.m4' libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
又搜了一下,在這篇BLOG說是因為沒安裝autoconf的原因,再回去安裝autoconf,如圖
?
再試一次libtoolize --copy --force
結果還是報同樣的錯誤,回頭去看(上面有圖,就是libtool那張)原來是libtool-debuginfo和cygwin64-libtool沒有安裝
于是安裝libtool-debuginfo和cygwin64-libtool
再試一次libtoolize --copy --force,成功運行
好了,繼續:./configure --prefix D:/ZThread/bin #--prefix指定編譯時輸出二進制文件的目錄
然后還是報錯,又運行libtoolize --copy --force,還是報錯,無語了
然后,上網搜了半天,在這里找到提示說使用:autoreconf --force --install --symlink
然后又報錯Can't exec "aclocal"
繼續搜,在這里找到提示說要安裝automake(然后我就去Cygwin-setup安裝了automake-1.8,注意不要重復安裝多個版本,否則會出問題)
?
然后輸入make install又提示make: command not found
還是同樣的套路,把make package給勾選安裝就行了
?