dtt27783 2017-02-14 16:13
浏览 258
已采纳

我如何通过MinGW安装依赖libiconv的go软件包

I am currently trying to set up a Go project, and considering I am running Windows, while the other 2 developers are working on a Mac, I have some trouble with installing a few packages.

After trying to install the packages with cmd, I was only able to install 2 out of 4. The other two needed gcc.

Therefore, I installed MinGW. I was able to install a third package that way, but now I am stuck on https://github.com/mikkyang/id3-go.

It seems to depend on another underlying project, https://github.com/djimenez/iconv-go. The moment I try to go install id3-go, I am always left with this error:

src\github.com\djimenez\iconv-go\converter.go:8:19: fatal error: iconv.h: No such file or directory

Somehow, I need to use libiconv with MinGW, but I have no idea how to connect both parts. I'm not really an expert in that field, so any help would be appreciated a lot. I already downloaded libiconv for Windows.

Related issue for additional information I found on the github project: https://github.com/mikkyang/id3-go/issues/21

EDIT: I made some progress on the whole problem. I now got all the files I need, but now I am stuck with this warning:

# github.com/djimenez/iconv-go
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
collect2.exe: error: ld returned 1 exit status

I tried to add the libiconv2.a from my libiconv installation to the mingw32 lib folder, but then this is what I end up with:

# github.com/djimenez/iconv-go
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib\libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib\libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
collect2.exe: error: ld returned 1 exit status

I have no idea how to proceed from here.

  • 写回答

1条回答 默认 最新

  • douhu2370 2017-02-25 15:09
    关注

    I've met the same problem when I want to go install github.com/google/gopacket which need CGO. It's because your libiconv2.a is generated by other compiler, so it's incompatible with mingw32 compiler as the error message says. We need generate the static lib with the mingw32 toolset:

    1. find libiconv-2.dll(the coresonding dynamic library) in your PC
    2. run gendef(located in C:\TDM-GCC-64\x86_64-w64-mingw32\bin in my 64-bit Windows ) on those files gendef libiconv-2.dll, this will generate libiconv2.def file
    3. Then generate the static library:

      dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libiconv2.a --input-def libiconv2.def

    4. copy libiconv2.a to proper location.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格