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

在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.

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

报告相同问题?

悬赏问题

  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络
  • ¥66 关于川崎机器人调速问题
  • ¥15 winFrom界面无法打开
  • ¥30 crossover21 ARM64版本安装软件问题
  • ¥15 mymetaobjecthandler没有进入
  • ¥15 mmo能不能做客户端怪物
  • ¥15 osm下载到arcgis出错