2016-05-28 09:28
浏览 498

在Cygwin64上编译cgo lib:“ ld:找不到-lmingw32”

I'm trying to use a cgo library on Windows, namely

I use Cygwin64 and installed with all "Development" packages, so gcc is availabe.

But running go get results in:

/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32

If I search for "mingwex" and "mingw32" in the Cygwin installer, I get no results. Am I looking for the wrong names or are they not available on 64 bit systems?

Or is there a better way to use the library on Windows?

Note that the README states that

However, if you install go-sqlite3 with go install, you don't need gcc to build your app anymore

but I get the same error message if I use go install.

$ go version
go version go1.6.2 windows/amd64

图片转代码服务由CSDN问答提供 功能建议

我正在尝试在Windows上使用cgo库,即 sqlite3


但是运行 go 在以下位置获取 结果:

  /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/.。  /../../../x86_64-pc-cygwin/bin/ld:找不到-lmingwex 
 / usr / lib / gcc / x86_64-pc-cygwin / 5.3.0 /../../。  ./../x86_64-pc-cygwin/bin/ld:如果我在Cygwin中搜索“ mingwex”和“ mingw32”,则找不到-lmingw32 

安装程序,我没有结果。 我是在寻找错误的名称还是在64位系统上不可用?

还是有更好的方法在Windows上使用该库? < hr>


但是,如果使用go install安装go-sqlite3 go-sqlite3,您不再需要gcc来构建您的应用

,但是如果我使用 go install < /code>。

$go version 
go版本go1.6.2 Windows / amd64 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • doumeng9188
    doumeng9188 2016-05-28 16:51

    What finally worked for me (instead of Cygwin) is to download TDM MinGW-w64 from and set the PATH such that gcc from C:\TDM-GCC-64\bin is used.

    点赞 评论
  • doujie3888
    doujie3888 2016-12-14 22:00

    I have encountered the same issue as well. It seems to me that cygwin is not fully compatible with cgo. Instead, I have used

    From the cgo documentation

    In order to use cgo on Windows, you'll also need to first install a gcc compiler (for instance, mingw-w64) and have gcc.exe (etc.) in your PATH environment variable before compiling with cgo will work.

    点赞 评论
  • dongpeiwei8589
    dongpeiwei8589 2017-04-25 15:57

    You can also install package mingw64-i686-gcc-core from Cygwin.

    The binary will be /usr/bin/i686-w64-mingw32-gcc.exe so you probably need to copy it as /usr/bin/gcc.exe.

    点赞 评论