【发布时间】:2019-07-19 19:32:56
【问题描述】:
对于我的一个二进制文件,CMake 会生成如下所示的命令行:
/opt/rh/devtoolset-8/root/usr/bin/g++
-O3 -DNDEBUG
-s
-Wl,--as-needed
-Wl,--gc-sections
<blah-blah>.o
...
-o procmon.e
-Wl,-rpath,/usr/local/lib64
<my lib>.a
...
/usr/local/lib64/libxalan-c.so
/usr/local/lib64/libxerces-c.so
/home/user/vcpkg/installed/x64-linux/lib/libcurl.a
...
-lcrypt
<more vcpkg static libs>
-lrt
-lpthread
<more vcpkg static libs>
-lm
<more vcpkg static libs>
-ldl
<more vcpkg static libs>
-pthread
<more vcpkg static libs>
如您所见,--as-needed 已指定,但我仍然得到未使用的依赖项:
$ ldd -u -r procmon.e
Unused direct dependencies:
/usr/local/lib64/libxalan-c.so.111
/lib64/libcrypt.so.1
/lib64/libm.so.6
为什么?
【问题讨论】: