dongxiaowei_1234 2017-03-27 22:21 采纳率: 0%
浏览 4021
已采纳

在Windows中构建Go项目时运行gcc失败

I tried compiling my project using go build and I get this error:

C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32 collect2: error: ld returned 1 exit status

I've read that linking files with gcc is a problem in compiling go projects with Windows. But I have installed gcc in my Windows system but the error persists. I can see the error above references gcc as in a Linux sistem (/usr/lib) so how would the compiler detect my gcc installation?

EDIT:

My go env

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\wildan\AppData\Loc
al\Temp\go-build554990027=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

Using go version 1.8

  • 写回答

1条回答 默认 最新

  • donglu6805 2017-03-28 01:14
    关注

    /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32 collect2

    You are using cygwin to look for mingw libraries. Don't use cygwin; use a mingw gcc compiler. I use TDM-GCC.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!