[已解決] 含gorm、sqlite3包的go程序構建失敗 C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1


問題描述

gorm官方文檔教程實例,構建出現錯誤。

C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1

沒有import這些包的其他代碼能夠正常構建

import (
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

報錯如下

PS L:\IT\Go\Codes\work\gorm> go run .   
# Work/work/gorm
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/..b/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: unrecognized option '--high-entropy-va'
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/..b/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: use the --help option for usage information
collect2.exe: error: ld returned 1 exit status

 

解決方法

http://tdm-gcc.tdragon.net/download

簡單來講 TDM-GCC 是一個 Windows 上的編譯器套件,集成了 GCC 工具集,提供了 MinGW 和 MinGW-w64 的運行時 API,可以執行編譯從 Windows98 開始的 32 位或者 64 位二進制文件。

下載安裝即可,重啟IDE,重新編譯。

如果還報錯,打開環境變量,選擇path進行編輯,找到 TDM-GCC-64\bin 將其上移

如果依舊報錯,嘗試直接添加其至 GOPATH 中


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM