dtu72460 2018-06-06 16:39
浏览 28

使用静态C库进行编译

I'm trying to compile Go where it includes all the libraries that I need to run it. I'm trying to run the go binary in lambda so I need to add some C libraries (I think) when I build it (on linux), but when I do, I get this error:

[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

I did a quick ldconfig search? and see this for example...are these the ones I need?

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序