doujiekeyan0622
doujiekeyan0622
2016-05-28 09:28
浏览 498

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

I'm trying to use a cgo library on Windows, namely github.com/mattn/go-sqlite3

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

But running go get github.com/mattn/go-sqlite3 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 github.com/mattn/go-sqlite3, 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库,即 github.com/mattn/go- sqlite3

我使用Cygwin64并安装了所有“开发”软件包,因此可以使用gcc。

但是运行 go 在以下位置获取github.com/mattn/go-sqlite3 结果:

  /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 github.com/mattn/ 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 http://tdm-gcc.tdragon.net/download 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 https://mingw-w64.org.

    From the cgo documentation https://github.com/golang/go/wiki/cgo:

    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.

    点赞 评论

相关推荐