Difference between -h <name> and -o <outputfile> parameters in cc (C ++)

I am creating a .so library and wondering what is the difference between b / w -h and -o cc complier option (using Sun Studio C ++)?

Don't they refer to the same thing - the name of the output file?

+3
source share
3 answers

-o is the name of the file that will be written to disk by the compiler

-h is the name that will be written to the ELF binaries that reference this file.

One common use case is to provide minor library version numbers. For example, if you create a shared libfoo library, you can:

cc -o libfoo.so.1.0 -h libfoo.so.1 *.o
ln -s libfoo.so.1.0 libfoo.so.1
ln -s libfoo.so libfoo.so.1

, hello world

cc -o hello -lfoo

hello NEEDED libfoo.so.1 ( . elfdump -d hello).

, , -o libfoo.so.1.1, -h libfoo.so.1 - , 1.0 libfoo.so.1 , , , ls, 1.1.

, , . , , , , , Makefiles :

cc -o libfoo.so.1.new -h libfoo.so.1 *.o
rm libfoo.so.1 ; mv libfoo.so.1.new libfoo.so.1

(Makefile, makefile Imake X, .)

+5

. , -o - . -h DT_SONAME . , . , ldd , .

+2

-o , -h . .

, :

elfdump -d xxx.so | grep SONAME

. :

http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter4-97194.html

+1
source

Source: https://habr.com/ru/post/1725232/


All Articles