pierreguillot / Camomile

An audio plugin with Pure Data embedded that allows to load and to control patches
GNU General Public License v3.0
902 stars 62 forks source link

Camomile plugins export pd/libpd symbols #157

Open Spacechild1 opened 4 years ago

Spacechild1 commented 4 years ago

The plugins should only export their entry points.

pierreguillot commented 4 years ago

Please, describe the problem and give further information.

Spacechild1 commented 4 years ago

Ah, sorry, should have been more specific. The Windows binaries export all symbols from the statically linked libpd. Generally, a VST plugin should only export its entry points. camomile_dependencies

pierreguillot commented 4 years ago

Ok, so it is a Windows-specific issue. I guess this is because the EXTERN macro is defined as __declspec(dllexport) extern. I should change that... Did you encounter any incompatibility?
Perhaps this is a dumb question but as these symbols are exported, I guess the plugin could load externals... It would be great if you could try ;)

Spacechild1 commented 4 years ago

Did you encounter any incompatibility?

Not really, but hiding symbols never hurts :-) But it's more of an issue on Linux than on Windows.

I guess the plugin could load externals...

that's true! Do I have to compile externals with PDINSTANCE? On Windows, this should actually work, I might give it a try. I guess on Linux you would have to dlopen externals with RTLD_DEEPBIND in case someone else already exported the Pd symbols. I already use RTLD_DEEPBIND in [vstplugin~], because otherwise Camomile would take the symbols from the Pd executable instead of the statically linked libpd, so for loading externals you would have to do the same. Unless we say that loading Camomile in Pd is a bad idea in the first place, but actually it was Miller himself who needed this for a project.

Spacechild1 commented 4 years ago

I think the fundamental problem is that Pd externals link against pd.dll and try to find/load a module of that name. At the moment I see two solutions:

1) Camomile links dynamically and ships libpd.dll (which all externals for Camomile can link against) 2) for every Camomile plugin, you have to link all externals against the plugin (instead of pd.dll)

I tried 2) and at least it didn't crash but I don't think my external actually loaded. Unfortunately, Camomile doesn't give me any console printout, so it's hard to tell where it fails. When I have more time, I can change the code so I can see the error messages.

pierreguillot commented 4 years ago

Camomile doesn't give me any console printout

The console is accessible by clicking on the top left flower. You can also define the warning level like in Pd.

Spacechild1 commented 4 years ago

ha, cool! it can find my external but can't load it. Now I need to do some printf debugging to find the reason.

pierreguillot commented 4 years ago

Yes I think externals must be compiled with PDINSTANCE. I will check all the definitions used by Camomile. I still don’t have a windows machine so it’s difficult for me to work for windows specific issues :(