views:

208

answers:

2

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.

+2  A: 

Use strip ?

$ man strip

Paul R
Strip won't stop the executable exporting symbols, if indeed it does, as it only takes debug info off.
MarkR
@MarkR: read the man page for strip - it can remove a lot more than just debug symbols
Paul R
But if you remove sections which are required to run, then the binary won't run any more, obviously :)
MarkR
+1  A: 

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.

MarkR