How to hidden all symbols(function name etc) use cmake build system?

hi:
I am trying to build juce with static library, and our app link the library. how can we remove symbol names from cmake?

To the best of my knowledge, there’s not really any way of changing symbol visibility in a static lib, beyond the normal internal/external linkage that is included in the core language (using keywords like static and extern).

Please provide more information about the problem. Why do you need to hide the symbols? Are you trying to desymbolicate the library for a release build so that third parties can’t see your function names? Are you trying to build multiple copies of JUCE into your application without encountering symbol collisisons?

yes. I linked the static library and can be found symbols on command nm on the binary, so I am asking desymbolicate the library for a release build.

I am afraid Reverse Engineering if not removed(hide) them.

You could try adding -s to your link flags to strip symbols.

One way of doing this is to supply -D CMAKE_MODULE_LINKER_FLAGS=-s when configuring your CMake project.

Another option is to add target_link_options (target PUBLIC "-s") to your plugin targets.

In both cases, you should only do this when you know the linker supports the -s flag.

When I build a VST3 with this flag enabled, I see that the only public/defined symbols remaining in the nm output are the GetPluginFactory functions, along with bundleEntry and bundleExit. There’s also a public repostCurrentNSEvent function that I think should probably be hidden - I’ll investigate a bit further and make that change in JUCE if it looks like a good idea.

All other public symbols are undefined symbols that are loaded from system libraries. No function signatures from JUCE or user code are made public.

I’ve made this change on the develop branch, hiding the repostCurrentNSEvent function:

With this change in place, a stripped JUCE VST3 plugin should only contain symbols for the VST3 entry-points, and any functions that must be loaded from system libraries.