Compiling

在 cygwin 下編譯 i3 - 找不到 libiconv 庫

  • May 23, 2018

我正在嘗試在 Cygwin 2.884 (Windows 7) 下編譯 i3 版本 4.14.1。我已經通過 Cygwin 安裝程序安裝了所需的 libiconv 庫,但是在執行 ./configure 時出現此錯誤:

configure: error: in `/home/msamec/Downloads/i3-4.14.1/x86_64-unknown cygwin':
configure: error: cannot find the required iconv_open() function despite trying 
to link with -liconv
See `config.log' for more details

有什麼線索可以幫助它找到圖書館嗎?

我曾嘗試手動編譯庫 libiconv-1.13.1 但遇到了一些我不知道如何解決的錯誤:

libtool: link: /bin/gcc -shared  .libs/localcharset.o .libs/relocatable.o      -o .libs/cygcharset-1.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libcharset.dll.a
.libs/relocatable.o: In function `DllMain':
/home/msamec/Downloads/libiconv-1.13.1/libcharset/lib/./relocatable.c:324: undefined reference to `cygwin_conv_to_posix_path'
/home/msamec/Downloads/libiconv-1.13.1/libcharset/lib/./relocatable.c:324:(.text+0x113): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `cygwin_conv_to_posix_path'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:59: libcharset.la] Error 1
make[2]: Leaving directory '/home/msamec/Downloads/libiconv-1.13.1/libcharset/lib'
make[1]: *** [Makefile:34: all] Error 2
make[1]: Leaving directory '/home/msamec/Downloads/libiconv-1.13.1/libcharset'
make: *** [Makefile:42: lib/localcharset.h] Error 2

我已經 grepped iconv_open() 函式名稱並在 cygwin 文件夾中找到它

/usr/i686-pc-cygwin/sys-root/usr/include/iconv.h

並且也在 libiconv 文件夾中

/usr/include/iconv.h

但由於某種原因,配置腳本無法找到它。

這是我的config.log

這是我的 iconv.h https://gist.github.com/anonymous/0b117d1680954d591f989256b508bfc5

我檢查了這個庫文件 inconv.h 在 Ubuntu 上的位置。Unlinke 在 cygwin 中位於 /lib/ 中,而在 cygwin 中位於 /usr/include/ 中。嘗試將庫複製到該位置,但這也無濟於事。我也能夠在我的家庭 Windows 10 上重現該問題。

編輯:這是我正在使用的配置文件:在此處輸入連結描述

測試失敗為

| char iconv_open ();
| int
| main ()
| {
| return iconv_open ();
|   ;
|   return 0;
| }
configure:6391: /bin/gcc -o conftest.exe    conftest.c -liconv  -lev  >&5
/tmp/ccz9hxNr.o:conftest.c:(.text+0xe): undefined reference to `iconv_open'
/tmp/ccz9hxNr.o:conftest.c:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `iconv_open'

iconv_open在圖書館找libiconv,錯了。測試程式碼應該使用提供/usr/include/iconv.h

#define iconv_open libiconv_open

和 cygwin 庫libiconv導出:

$ objdump -x /usr/lib/libiconv.dll.a | grep iconv_open
[  5](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 libiconv_open_into
[  6](sec  3)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 __imp_libiconv_open_into
[  5](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 libiconv_open
[  6](sec  3)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 __imp_libiconv_open

符號libiconv_open。您需要更正測試才能使用iconv.h.

測試定義在configure.ac

AC_SEARCH_LIBS([iconv_open], [iconv], , [AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])])

一種可能的解決方法是更改​​它以測試這兩個選項。

AC_SEARCH_LIBS([iconv_open],[iconv],,
AC_SEARCH_LIBS([libiconv_open],[iconv],,[AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])]))

免責聲明:未經測試,您需要執行autoreconf才能重建configure

引用自:https://unix.stackexchange.com/questions/445374