我正在嘗試在 Windows 上的 Go 項目中使用 hunspell 庫。我有已編譯的 Windows DLL (x64)和相應的頭文件(用 C 編寫),但我無法將它鏈接到 Go 程序。到目前為止我已經嘗試過:package main//#cgo CFLAGS: -Id:/Go/HunSpellTest/build///#cgo LDFLAGS: -Ld:/Go/HunSpellTest/build/llibhunspell-1.7-0.dll -llibhunspell-1.7-0// #include <stdlib.h>// #include <hunspell.h>import "C"import ( "unsafe")func main() { C.Hunspell_create()}但是對于路徑和文件名的任意組合(有擴展名,沒有擴展名,沒有版本號,有相對和絕對路徑,使用斜杠或反斜杠)我得到了同樣的錯誤:undefined reference to __imp_Hunspell_create我試圖將該路徑添加到全局PATH變量或將 DLL 放入系統范圍的文件夾中,但沒有任何效果。請注意,我可以將 DLL 與syscall包鏈接并調用該Hunspell_create方法,但我想使用hunspellgo包中的 lib。
1 回答

米脂
TA貢獻1836條經驗 獲得超3個贊
C.Hunspell_create()
缺失const char* affpath
和const char* dpath
參數。
也許您還缺少mingw-w64/msys2/cygwin
Windows 上的一些 deps 包。hunspellgo似乎沒有在 Windows 上測試過。您需要一個類似 linux 的構建系統(例如mingw-w64/msys2/cygwin
)來在 Windows 上編譯 hunspell。請參閱https://github.com/hunspell/hunspell#compiling-on-windows。在 Windows 上支持 cgo 的 Golang 也需要一些gcc/g++
依賴。
- 1 回答
- 0 關注
- 378 瀏覽
添加回答
舉報
0/150
提交
取消