编译去静态c库

时间:2018-06-06 16:39:46

标签: go

我正在尝试编译Go,其中包含运行它所需的所有库。我正在尝试在lambda中运行go二进制文件,所以当我构建它(在linux上)时我需要添加一些C库(我认为),但是当我这样做时,我得到了这个错误:

[ec2-user@ip- src]$ go build -tags static --ldflags '-extldflags "-static -lpthread -lxml2 -lz -lm -llzma -lc"' main.go
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lxml2
/usr/bin/ld: cannot find -lz
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -llzma
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status

--- EDIT00000

我进行了快速ldconfig搜索?并且看到这个例子......这些是我需要的吗?

ldconfig -p | grep -e xml2 -e pthread -e lzma -e dl 
    libxml2.so.2 (libc6,x86-64) => /lib64/libxml2.so.2
    libreadline.so.6 (libc6,x86-64) => /lib64/libreadline.so.6
    libpthread.so.0 (libc6,x86-64, OS ABI: Linux 2.6.32) => /lib64/libpthread.so.0
    liblzma.so.5 (libc6,x86-64) => /lib64/liblzma.so.5
    libhandle.so.1 (libc6,x86-64) => /lib64/libhandle.so.1
    libgpgme-pthread.so.11 (libc6,x86-64) => /lib64/libgpgme-pthread.so.11
    libdl.so.2 (libc6,x86-64, OS ABI: Linux 2.6.32) => /lib64/libdl.so.2
    libdl.so (libc6,x86-64, OS ABI: Linux 2.6.32) => /lib64/libdl.so

0 个答案:

没有答案