This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Fwd: when should --no-undefined flag be used for shared libraries
- From: Domen Vrankar <domen dot vrankar at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 3 Nov 2014 11:06:55 +0100
- Subject: Fwd: when should --no-undefined flag be used for shared libraries
- Authentication-results: sourceware.org; auth=none
- References: <CAKgx6B+3K0SOJoE0pVgdrZ=spsxH0u1qnnHH3a2CtACJTGeO2A at mail dot gmail dot com>
Hello,
I have posted a question regarding this a few days ago on stack
overflow and until now no one was able to answer my question.
Here is the link to original question:
http://stackoverflow.com/questions/26626789/when-should-no-undefined-flag-be-used-for-shared-libraries
And here is a copy of the question:
Let us say that we have the following library dependencies (lib are
shared libraries)
lib1 lib2 lib3 lib4
| | | |
-------lib5 lib6----
| | | |
lib7 | | |
| | | |
-------exe--------------
I decided to build all libraries with -fvisibility=hidden and
-Wl,--no-undefined compiler flags.
exe requires lib4, lib5, lib6 and lib7. It does not directly require
lib1, lib2 and lib3.
lib1 is linked both to lib5 and lib7 but its symbols are hidden from
exe because -fvisibility=hidden is used.
lib4 has to be directly linked to exe even though lib6 is already
linked to it because -fvisibility=hidden hides all lib3 symbols that
are used by lib6.
My question is if there is any reason not to use -Wl,--no-undefined
flag with shared libraries in any of the above cases (or cases that I
haven't thought of)?
Thanks,
Domen