原文連接: http://www.code-by.org/viewtopic.php?f=54&t=166php
GNU頁面
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gzexpress
已有的環境:msys2.0, mingw, GnuWin32工具集app
解壓後先別急着configure
先看看 README.woe32ide
Building requires the mingw or cygwin development environment (includes gcc).
I recommend to use the cygwin environment as the development environment
and mingw only as the target (runtime, deployment) environment.
For this, you need to install工具
首先安裝cygwin,
進入目錄後執行 ./configure , 第一個問題ui
checking if gcc supports -fno-rtti -fno-exceptions... ./configure: line 7594: diff:
command not foundthis
缺個diff.exe,用everything 搜索到 C:\Program Files (x86)\GnuWin32\bin 下面有一個,複製到 C:\cygwin64\bin,
先不急着執行./configure,單獨執行diff.exe 提示缺乏 libintl3.dll,將這個文件也複製過來,
再次執行diff.exe 提示缺乏 libiconv2.dll,再複製,沒問題了。
(若是你從別的地方獲取diff,可能不須要依賴dll,也可能依賴別的庫,用相似的方法配置齊全就是了)code
執行 ./configure 沒有出現明顯問題token
執行 make ,提示ci
./relocatable.c: In function 'libcharset_relocate':
./relocatable.c:423:37: note: in expansion of macro 'INSTALLDIR'
const char
orig_installdir = INSTALLDIR;
^~~~~~~~~~
make[2]: ** [Makefile:65: relocatable.lo] Error 1
make[2]: Leaving directory 'C:/Users/ViANG/Desktop/libiconv-1.14/libcharset/lib'
make[1]: *** [Makefile:34: all] Error 2
make[1]: Leaving directory 'C:/Users/ViANG/Desktop/libiconv-1.14/libcharset'
make: *** [Makefile:42: lib/localcharset.h] Error 2
好像是說這個 INSTALLDIR 的宏裏面,包含了不可預料的表達式(在/以前),可是我也不知道怎麼看INSTALLDIR的值,
用grep -R "INSTALLDIR" * 看了一下
build-aux/install-reloc: -D"INSTALLPREFIX="$prefix"" -D"INSTALLDIR
="$installdir"" lib/Makefile:-DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR="$(libdir)" -DNO
_XMALLOC lib/Makefile.in:-DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR="$(libdir)" -
DNO_XMALLOC
大概是從某個參數中傳遞進去的,既然它的內容有毒,並且只有一處,那本身改寫試試:
找到:libiconv-1.14\libcharset\lib\relocatable.c
將
const char orig_installdir = INSTALLDIR;
改成
const char orig_installdir = "/usr/local/cygwin";
同時 mkdir /usr/local/cygwin
而後執行
$ ./configure --prefix=/usr/local/cygwin
$ make
提示錯誤
C:\MinGW\bin\ranlib.exe: '/cygdrive/c/Users/name/Desktop/libiconv-1.14/lib/libcharset.a':
No such file
試了一下,對於mingw和msys的那一套,能夠接受的路徑是 /c/usr/...這樣的,而在cygwin中的路徑是 /cygdrive/c/usr...
試着用sed和grep 批量替換,以及尋找 生成路徑的 cygpath命令,修改相應的參數,但仍是失敗了。
分割線
既然Cygwin 路徑和 Msys mingw不兼容,而我對這一系列的東西不太熟,只能再換MSYS試試了
按cygwin的方法把diff.exe和相關的文件複製到 c:/mingw/bin
打開 MSYS2 Shell
$ ./configure
configure: error: cannot guess build type; you must specify one
添加參數:
$ ./configure --build=mingw32
看上去沒什麼問題
$ make
跑了一大段後,出現前面一樣的問題:
./relocatable.c: In function 'libiconv_relocate':
./relocatable.c:423:37: note: in expansion of macro 'INSTALLDIR'
const char
orig_installdir = INSTALLDIR;
^~~~~~~~~~
each function it appears in./relocatable.c:423:37: note: in expansion of macro 'INSTALLDIR'
const char
^~~~~~~~~~
./relocatable.c:423:37: note: in expansion of macro 'INSTALLDIR'
const char
orig_installdir = INSTALLDIR;
^~~~~~~~~~
make[1]: ** [Makefile:87: relocatable.lo] Error 1
make[1]: Leaving directory 'C:/Users/ViANG/Desktop/libiconv-1.14/lib'
make: *** [Makefile:33: all] Error 2
找到 libiconv-1.14/lib/relocatable.c
改 INSTALLDIR 爲 "/usr/local/cygwin" (忘了去mkdir,好像也沒什麼問題),繼續
$ make
$ make install
看上去沒什麼問題了 :coverface1