我正在Solaris 10上构建redis C客户端,生成动态库的最后一步是这样的:
cc -G -o libhiredis.so -h libhiredis.so.0.11 net.o hiredis.o sds.o async.o
cc
引用gcc
:
bash-3.00# which cc
/usr/local/bin/cc
bash-3.00# ls -lt /usr/local/bin/cc
lrwxrwxrwx 1 root root 3 Mar 24 2011 /usr/local/bin/cc -> gcc
bash-3.00# /usr/local/bin/gcc -v
Reading specs from /data/local/bin/../lib/gcc/sparc-sun-solaris2.10/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld -- enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6
从https://gcc.gnu.org/onlinedocs/gcc/Option-Index.html,我知道" -G"选项是"创建共享对象"。但" -h"是什么?意思?我无法在https://gcc.gnu.org/onlinedocs/gcc/Option-Index.html中找到它。
答案 0 :(得分:5)
它是一个链接器选项(只需用' man ld'进行检查):
-h name
-soname=name
When creating an ELF shared object, set the internal DT_SONAME
field to the specified name. When an executable is linked with a
shared object which has a DT_SONAME field, then when the executable
is run the dynamic linker will attempt to load the shared object
specified by the DT_SONAME field rather than the using the file
name given to the linker.