Ld warning about visibility

When I compile my plugin, I get the following ld warning

ld: warning: direct access in function 'pongasoft::VST::GUI::Views::TextEditView::setListener(VSTGUI::IControlListener*)' from file 'lib/Debug/libjamba.a(TextEditView.cpp.o)' to global weak symbol 'typeinfo for VSTGUI::IControlListener' from file 'lib/Debug/libvstgui_support.a(vst3editor.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

It’s on macOS 10.14.6 with Xcode 11.3.1. It is using the latest SDK 3.7.5 and this warning was not occurring in 3.7.1.

I know it is just a warning, but I would like to get rid of it and I am not sure what I need to do to make it go away. Any idea?

Thanks

This means that libjamba.a and libvstgui_support.a are build with different settings which should be avoided in c++. In your case it’s the “symbol visibility” setting. I think the SDK uses the default Xcode setting.

So I recompiled my code to see what is going on:

For TextEditView.cpp I see those options: -fvisibility=hidden -fvisibility-inlines-hidden

For vst3editor.cpp those options are not present.

In my (build) code I use smtg_setup_symbol_visibility() which does the following

macro(smtg_setup_symbol_visibility)
    set(CMAKE_C_VISIBILITY_PRESET hidden)
    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endmacro(smtg_setup_symbol_visibility)

So I assume this is why I end up with those visibility flags. But it looks like vst3editor.cpp is not using them. Not too sure why.

I think I found the issue and the problem is in the sdk.

My code is following what the generated plugin does (using the VST3 generator included) like this:

set(SMTG_VSTGUI_ROOT "${vst3sdk_SOURCE_DIR}")
add_subdirectory(${vst3sdk_SOURCE_DIR} ${PROJECT_BINARY_DIR}/vst3sdk)
smtg_enable_vst3_sdk()

smtg_enable_vst3_sdk() calls smtg_setup_symbol_visibility() which enables these flags. And for some reasons these flags are not set for VSTGUI…

If instead I do this:

set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(SMTG_VSTGUI_ROOT "${vst3sdk_SOURCE_DIR}")
add_subdirectory(${vst3sdk_SOURCE_DIR} ${PROJECT_BINARY_DIR}/vst3sdk)
smtg_enable_vst3_sdk()

on in other words these flags must be set before add_subdirectory

Then it fixes the issue…

Hmm, I will check again, but I don’t have any ld warnings with my plug-ins. Also the SDK examples don’t produce this warning.

Maybe it’s because some of my code is compiled in a library which is then linked to the plugin. Or just because of my usage of the classes (like overriding methods, etc…)

The fact of the matter, though, is that if you check the output of the build for vst3editor.cpp you can see that -fvisibility=hidden is not included. I just checked it with a plugin generated via the generator included and there is not such flag for vst3editor.cpp. Why it generates a warning in my case or not in other cases is a mystery but it seems that vst3editor.cpp should be compiled with the same flags in terms of visibility. And it’s not.

Yeah I know, this is what I wanted to check or actually will check at some point.