Normally I don't make static libraries, only DLLs or EXEs. But after having to deal with a piece of code that I have copied and pasted into virtually all of my programs lose its versioning (so I don't know which copy is up to date), I have decided on compiling it into a static library and linking against that.
The thing is, when I make the lib (MSVC 2005), its symbol table seems to be chock full of functions, when the only thing that I want visible to the linker at the end is one function and a reference to an external variable.
Reading around, one thing I can do is declare each function that I want to be hidden from the linker as static. All this seems to do is change the storage class for the functions from "External" to "Static". This prevents linkers from using the reference, assuming that they are well behaved. But the implementation leak is still there.
Other things that I have read include using attribute((visibility("hidden"))), which is GNU C-specific, and __declspec(dllexport) on only the elements that I want to export, which seems to have no effect (more likely for DLL use only).
I suspect that I would need a tool to do this. But surely there must be a way of telling the compiler that "this stuff is not to be externally referenced, compile it as one big chunk"?