I am building .so library and was wondering – what is the difference b/w -h and -o cc complier option (using the Sun Studio C++) ?
Aren’t they are referring to the same thing – the name of the output file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
-ois the name of the file that will be written to disk by the compiler-his the name that will be recorded in ELF binaries that link against this file.One common use is to provide library minor version numbers. For instance, if
you’re creating the shared library libfoo, you might do:
Then if you compile your hello world app and link against it with
the elf binary for hello will record a
NEEDEDentry forlibfoo.so.1(which you cansee by running
elfdump -d hello).Then when you need to add new functions later, you could change the
-ovalue tolibfoo.so.1.1but leave the -h atlibfoo.so.1– all the programs you already builtwith 1.0 still try to load
libfoo.so.1at runtime, so continue to work without beingrebuilt, but you’ll see via ls that it’s 1.1.
This is also sometimes used when building libraries in the same directory they’re
used at runtime, if you don’t have a separate installation directory or install
via a packaging system. To avoid crashing programs that are running when you
overwrite the library binary, and to avoid programs not being able to start when
you’re in the middle of building, some Makefiles will do:
(Makefiles built by the old Imake makefile generator from X commonly do this.)