Question

I'm finding that when I link an executable against a static library (.a), the symbols from the static library end up being exported by the executable file. I would like to avoid this and export nothing.

I've tried providing a version script, but it seems to make no difference. The contents of my version script are as follows:

{
    global:
        main;
    local:
        *;
};

Is there a way to not export symbols from an executable when linking in a static library? I can't recompile the static library itself.

Was it helpful?

Solution

Executables don't export symbols by default, and will not do so unless you use -Wl,--export-dynamic. This is necessary only if you're dynamically loading libraries that themselves need to link into symbols in the main executable (this is a common case in C++ if your libraries contain classes which override virtual methods in the exe)

Perhaps you're confusing exporting symbols with having debug symbols. Debug symbols will be produced for the benefit of the debugger (if you don't strip the exe), but are not required to run.

OTHER TIPS

Use strip ?

$ man strip

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top