only export interface symbols from shared libraries on non-Windows#82
only export interface symbols from shared libraries on non-Windows#82
Conversation
|
This does work, but doesn't do exactly what you set out to accomplish. Since you set visibility for the source directory it only applies to targets defined in the source directory, so the third party libraries are still have default visibility. But ZMusic itself is only exposing the symbols explicitly exported. Edit: Realized my final sentence may sound contradictory so here's the symbol diff |
|
Two ways to fix the rest of the symbols:
Probably a good idea to set the linker option from 2 even if doing 1 as insurance. Since it shouldn't cause any crazy deltas option 1 is probably the better way to solve it. |
|
The preset was supposed to be in the root project file, I must have picked the wrong one - as Visual Studio's file list does not show the paths and with all project files having the same name, it was easy to slip up. Please try again. |
|
Better, but like I said, you do need to deal with the libraries that set default visibility on their symbols (i.e. Also just remembered there's CMAKE_VISIBILITY_INLINES_HIDDEN you'll probably want to turn on. |
|
Can you give me a list of currently visible symbols? Without anything to check against this is like poking in the dark. |
|
Sure: symbols.txt Based on the way you went about fixing GME, I think we're good here. The others I listed in my second reply happen to not be a problem since (I think) we wrote our own CMakeLists for them so we happen to not define the relevant constant to cause symbols to leak. It is my understanding that some std:: symbols are unavoidable so don't pay much attention to them. (They're all weak symbols.) Don't know the specific details on the why. I'd probably still suggest the link option I noted in my second reply for a little extra insurance, but under normal configuration it should make no difference. |
|
Ok. It looks like this is a deliberate design decision. What's interesting here is that none of the exported symbols is for vectors of custom types, only for vectors of native types and std::string. I could go ahead and reduce it a bit more by using TArray instead of std::vector but that sounds a bit like overkill with no real gain. |
| #define DLL_EXPORT __declspec(dllexport) | ||
| #define DLL_IMPORT __declspec(dllexport) // without this the compiler complains. | ||
| #if !defined(ZMUSIC_STATIC) | ||
| #if defined(_MSC_VER) |
There was a problem hiding this comment.
MinGW/MinGW-w64 does the absolutely same, so please use _WIN32 here.
|
Done |
|
amazing |
This needs testing on an actual Linux and macOS system to make sure it actually works.
I'd find it preferable if zmusic only exported its public interface and not the innards of the various third party libraries it includes to avoid symbol name clashes.
Attempt to fix #72