3
繼我的earlier question之後,現在我在嘗試從此article執行所有相同步驟時遇到此錯誤,因爲我已從Go 1.6.1升級到Go 1.7。 1(我無法回到Go 1.6.1,因爲鏈接器在嘗試編譯某些共享庫時崩潰)。不能隱式地在共享庫中包含運行時/ cgo
我做了什麼:
-
在
- 安裝去(這是後來被稱爲
GOROOT
)。 編譯
libstd.so
:GOROOT=~/.go/go GOPATH=~/tests go install -buildmode=shared -linkshared std
編譯
calc
庫:GOROOT=~/.go/go GOPATH=~/tests go install -a -x -buildmode=shared -linkshared calc
試圖編譯
app
:GOROOT=~/.go/go GOPATH=~/tests go build -a -x -linkshared -o app cashier
,並收到此錯誤:
~/.go/go/pkg/tool/linux_amd64/link: cannot implicitly include runtime/cgo in a shared library
~/.go/go
我想重複這些步驟與CGO_ENABLED=0
前置到環境中,但沒有將建立這種方式。給我這個錯誤:
imports runtime/cgo: C source files not allowed when not using cgo or SWIG: gcc_fatalf.c gcc_linux_amd64.c gcc_mmap.c gcc_util.c
這是一個已知的錯誤嗎?是否讓共享庫支持?