盡管cannot find lpcap我已經安裝了libpcap-devel.go build -i -ldflags "-linkmode external -extldflags -static -X main.version=git-6e3f8a1c7a0a" -tags netgo -o prog/weaver/weaver ./prog/weaver# github.com/weaveworks/weave/prog/weaver/go/pkg/tool/linux_s390x/link: running s390x-linux-gnu-gcc failed: exit status 1/usr/lib64/gcc/s390x-suse-linux/7/../../../../s390x-suse-linux/bin/ld: cannot find -lpcap/tmp/go-link-225248852/000015.o: In function `mygetgrouplist':/tmp/workdir/go/src/os/user/getgrouplist_unix.go:15: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking我可以在以下位置看到 .so 文件 /usr/lib64 # ls | grep pcap libpcap.so libpcap.so.1 libpcap.so.1.8.1
2 回答

慕慕森
TA貢獻1856條經驗 獲得超17個贊
openSUSE開發 RPm?不提供 static?,因此您不能靜態鏈接,除非libpcap
您能夠從源代碼(以及同樣適用的任何其他庫)構建靜態庫。libpcap.a
libpcap
如果您可以選擇動態鏈接您的 go 程序,那么-static
從您的項目中刪除可以避免這個問題。-ldflags

隔江千里
TA貢獻1906條經驗 獲得超10個贊
安裝庫的開發版本,您將獲得標頭和 .a 文件以及 .so 共享庫
C 鏈接器需要這些用于靜態鏈接
此外,構建過程需要能夠找到 .a 文件。這應該會自動發生,但您可以幫助它
找到 .a 文件所在的目錄(例如通過列出您用于安裝的包)并在您的 ldflags 中添加帶有 -L 選項的目錄
- 2 回答
- 0 關注
- 363 瀏覽
添加回答
舉報
0/150
提交
取消