Go-使用race参数时报错:libgcc(.text): relocation target atexit not defined解决方案

234 阅读1分钟

错误代码

PS F:\Go-Concurrent\channel> go run -race .\channel1.go
D:/Golang/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmsvcrt.a(/1809): duplicate symbol reference: _
unlock_file in both libgcc(.text) and libgcc(.data)
libgcc(.text): relocation target atexit not defined

go版本:1.18
环境:win10

报错原因,时机

过程、解决办法

  • 在使用race参数时,报错,由于使用race参数不多,一开始以为是gcc环境问题,调整gcc位置,并且尝试mingw和msys2后发现都不行
  • 然后安装了新的版本:1.19
  • 再次运行没有报错,删除掉1.18之后重新下载,发现又没报错了

思索原因

  • 由于在学习一些标准库的源码时,可能不小心对源码进行了改动
  • 搞了一晚上,可恶啊!