You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MSYS2 MINGW64环境下Go编译提示找不到lmingwex和lmingw32的解决方法

解决MSYS2 MINGW64环境下Go build时找不到-lmingwex/-lmingw32的问题

问题场景

在MSYS2 MINGW64环境中安装go version go1.19 windows/amd64,执行go build时出现链接错误:

I:\msys2\mingw64\lib\go\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lmingwex: No such file or directory
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lmingw32: No such file or directory
collect2: error: ld returned 1 exit status

解决步骤

  • 确认使用MinGW64 Terminal:不要用MSYS默认终端,打开MSYS2菜单中的MinGW64 Terminal,该终端默认配置了MINGW64工具链的环境变量。
  • 安装/更新MINGW64工具链:在MinGW64终端执行命令,安装包含所需库的工具链包:
    pacman -S mingw-w64-x86_64-toolchain
    
    若已安装,执行更新确保库文件完整:
    pacman -Syu mingw-w64-x86_64-toolchain
    
  • 验证链接器路径:执行which ld,输出应为/mingw64/bin/ld。若显示/usr/bin/ld,需将/mingw64/bin加入PATH最前端,确保优先使用MINGW64的链接器。
  • 重新编译:在MinGW64终端进入项目目录,执行go build即可。

内容的提问来源于stack exchange,提问作者rnso

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 22:56:30