Fwd: when should --no-undefined flag be used for shared libraries

Domen Vrankar domen.vrankar@gmail.com
Mon Nov 3 10:07:00 GMT 2014


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:


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     |        |        |
 |       |        |         |

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)?


More information about the Gcc-help mailing list