zoukankan      html  css  js  c++  java
  • 使用MinGW 编译 iconv 库

    原文链接: http://www.code-by.org/viewtopic.php?f=54&t=166

    GNU页面
    http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

    已有的环境:msys2.0, mingw, GnuWin32工具集

    解压后先别急着configure
    先看看 README.woe32

    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,
    • the mingw runtime package, also from the cygwin site.

    首先安装cygwin,
    进入目录后执行 ./configure , 第一个问题

    checking if gcc supports -fno-rtti -fno-exceptions... ./configure: line 7594: diff:
    command not found

    缺个diff.exe,用everything 搜索到 C:Program Files (x86)GnuWin32in 下面有一个,复制到 C:cygwin64in,
    先不急着执行./configure,单独执行diff.exe 提示缺少 libintl3.dll,将这个文件也复制过来,
    再次执行diff.exe 提示缺少 libiconv2.dll,再复制,没问题了。
    (如果你从别的地方获取diff,可能不需要依赖dll,也可能依赖别的库,用类似的方法配置齐全就是了)

    执行 ./configure 没有出现明显问题

    执行 make ,提示

    ./relocatable.c: In function 'libcharset_relocate':
    :0:12: error: expected expression before '/' token
    ./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.14libcharsetlib elocatable.c


    const char *orig_installdir = INSTALLDIR;
    改为
    const char *orig_installdir = "/usr/local/cygwin";

    同时 mkdir /usr/local/cygwin
    然后执行
    $ ./configure --prefix=/usr/local/cygwin
    $ make
    提示错误

    C:MinGWin anlib.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':
    :0:12: error: 'C' undeclared (first use in this function)
    ./relocatable.c:423:37: note: in expansion of macro 'INSTALLDIR'
    const char *orig_installdir = INSTALLDIR;
    ^~~~~~~~~~
    :0:12: note: each undeclared identifier is reported only once for
    each function it appears in./relocatable.c:423:37: note: in expansion of macro 'INSTALLDIR'
    const char *orig_installdir = INSTALLDIR;
    ^~~~~~~~~~
    :0:13: error: expected ',' or ';' before ':' token
    ./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

  • 相关阅读:
    互联网创业瞄准Web3.0时代 风投商造梦与毁梦 沧海
    SOA基础结构探究:服务调节与指挥 沧海
    排序算法小结 沧海
    上班触感 沧海
    经典程序摘录 沧海
    经典C程序100例 沧海
    ITIL进入快速增长期 2010年亚太市场将达$8亿 沧海
    必须要掌握的七种谈话技巧 沧海
    如何准备软件工程师的面试 沧海
    Junit教程 拂晓风起
  • 原文地址:https://www.cnblogs.com/paktc/p/5997500.html
Copyright © 2011-2022 走看看