linux-cmake静态编译
CMakeLists.txt 添加
set(CMAKE_EXE_LINKER_FLAGS "-static")
ELF 64-bit LSB executable, AMD x86-64, version 1 (GNU/Linux), for GNU/Linux x.x.x.x, statically linked,
查看系统支持的的libc版本
strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
...
查看程序需要的动态链接库
ldd /bin/bash
linux-vdso.so.1 => (0x00007ffff5d60000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000)
libc.so.6 => /lib64/libc.so.6 (0x0000)
/lib64/ld-linux-x86-64.so.2 (0x0000)
查看程序需要的libc版本
readelf -aW /bin/bash|grep GLIBC_2.
freebsd下
readelf -aW /bin/bash|grep FBSD