我試圖在 Linux 中將一些在 Nim 中創(chuàng)建的代碼靜態(tài)鏈接到 Go 應(yīng)用程序中。我已經(jīng)關(guān)注了Nim 后端集成文檔和一些在 Go 中鏈接 C 的文章,但沒有讓它工作。到目前為止,我在這里...尼姆代碼target.nim:proc testnim* {.exportc.} = echo "In Nim!"我編譯它:nim c --app:staticLib --noMain --header target.nim去代碼app.go:package main/*#cgo CFLAGS: -I/my/path/to/target/nimcache#cgo CFLAGS: -I/my/path/to/Nim/lib#cgo LDFLAGS: /my/path/to/target/libtarget.a#include "/my/path/to/target/nimcache/target.h"*/import "C"import "fmt"func main() { fmt.Println("In Go!") C.NimMain() C.testnim()}我嘗試構(gòu)建這兩個:go buildgo build --ldflags '-extldflags "-static"' app.go這是我得到的:# 命令行參數(shù)/my/path/to/target/libtarget.a(stdlib_system.o):在函數(shù)‘nimUnloadLibrary’中:stdlib_system.c:(.text+0xe6f0):對`dlclose'的未定義引用/my/path/to/target/libtarget.a(stdlib_system.o):在函數(shù)‘nimLoadLibrary’中:stdlib_system.c:(.text+0xe71b):對`dlopen'的未定義引用/my/path/to/target/libtarget.a(stdlib_system.o):在函數(shù)‘nimGetProcAddr’中:stdlib_system.c:(.text+0xe750):對`dlsym'的未定義引用collect2: 錯誤: ld 返回 1 個退出狀態(tài)所以我錯過了一些東西。我正在使用 Go 1.5 和 Nim 0.11.3(開發(fā)分支)。任何建議或提示將不勝感激。
- 1 回答
- 0 關(guān)注
- 203 瀏覽
添加回答
舉報
0/150
提交
取消