Where to put my .dylib ?
-
Hi. I haven't massively familiarized myself with your problem, but I just stumbled across this in the documentation and thought it sounded related:
DLLs needed by a plugin can be placed in myplugin\res\libs\win64; DYLIBs can be placed in myplugin\res\libs\osx.
-
Hi,
@sgeggie was faster than me...
There's also the Development for macOS page containing some information.
Please note that this behavior changed a bit in Cinema 4D R20 and we are assuming you are looking for information on R20 here.I have moved this thread into the Cinema 4D Development category. And I also changed this thread into a question and added a tag. Would be nice if you could add another tag regarding the Cinema 4D version you are asking for.
Cheers,
Andreas -
Hm, still the same issue...
I hope this is a beginners problem. So my setup is this:
my project file ( designfabric.vcxproj ) lies here:
Cinema 4D R20/sdk/plugins/designfabric/project/designfabric.vcxproj
was created with Project Tool
sources are beneath:Cinema 4D R20/sdk/plugins/designfabric/source
Is this the right location ? (should it developed inside /plugins ? - guess no)
there is also a res folder with the dylib, here:Cinema 4D R20/sdk/plugins/designfabric/res/libs/osx/libxl.dylib
If I compile and start Cinema with Xcode the plugin only starts if there is libxl.dylib here:
Cinema 4D R20/sdk/build/Release/libxl.dylib
How to distribute Plugins?
Is it only copying the .xlib somewhere in plugins ? Must it have a res folder? other things?Strange thing is if I compile another project with Xcode than my old designfabric.xlib inside plugins find the dylib inside sdk/build/Release and shows up. I really don't get it. Im totally messed with the paths.
Quite desperated I begun to port the whole project to Windows C4D R 19. Everything compiled nice, dlls loaded, but it wasn't possible to copy these plugins to another windows machine (the c4dsdkexample either)... em... so Im back on Mac R20 and trying to explain my boss: ok, you have to start Cinema 4D by Xcode and its only working on THIS computer.
Hope you have some clues for me, Greetings ascorbin
-
Hi ascorbin
sources are beneath:
Cinema 4D R20/sdk/plugins/designfabric/source
Is this the right location ? (should it developed inside /plugins ? - guess no)No, actually the sdk.zip (or rather its extracted content) doesn't even need to located inside of Cinema 4D's program folder, see Plugin Development. With Cinema 4D R20 you can point Cinema to multiple plugin folders located anywhere, either via the preferences, command line arguments (
g_additionalModulePath=...
) or environment variables.there is also a res folder with the dylib, here:
Cinema 4D R20/sdk/plugins/designfabric/res/libs/osx/libxl.dylibThis looks about right to me.
If I compile and start Cinema with Xcode the plugin only starts if there is libxl.dylib here:
Cinema 4D R20/sdk/build/Release/libxl.dylibHm? This sounds strange. Where is the additional
build/Release
sub-directory coming from and was it configured in any way, either inprojectdefinition.txt
or manually in your Xcode project?
Also how do you make use of this additional dynamic library, is it linked dynamically or maybe loaded deferred manually?How to distribute Plugins?
Usually the plugin's folder in plugins directory gets zipped, containing the plugin binary (or binaries if multiple platform) and the res folder containing all libraries and resource files needed. And a user can simply unzip it in her/his preferred plugins location.
Quite desperated I begun to port the whole project to Windows C4D R 19. Everything compiled nice, dlls loaded, but it wasn't possible to copy these plugins to another windows machine (the c4dsdkexample either)... em... so Im back on Mac R20 and trying to explain my boss: ok, you have to start Cinema 4D by Xcode and its only working on THIS computer.
Please note, in terms of dynamic libraries R19 behaved differently than R20. But in regards to not being able to copy your R19 plugin from one machine to another, could it be, you just did debug builds and not release builds? A debug build of a plugin needs a different C runtime environment, that usually only exists on systems with Visual Studio installed. While you could install it manually on the other machines, I recommend to rather do a release build and distribute that instead.
Cheers,
Andreas -
Hi Andreas
Thanks a lot for your detailed answer.
Concerning this additional build/Release sub directory. After a complete fresh install (unzipping ski.zip, running kernel_app.app/Contents/MacOS/kernel_app g_updateproject=/Users/lenaamrhein/PROGRAMMING/C4D/sdk and compiling) my folder structure looks like this:Build path settings in Xcode
So these build/Release-Folder aren't intended? Is it a feature of Xcode 10.1 ?
greetings ascorbin
-
No, no, it's all fine. It was just me being stupid. I checked the directory structure here on Windows, only, and forgot about the differences.
I don't think, you should need to place external libraries in these temporary folders. They should reside inside of your plugins folder. I'll do some more testing, if there's anything we forgot in the documentation. -
The issue is still not solved. I had success with R19 & R20 on Windows with the same lib as DLL. On Mac I suspect System Integrity Protection and DYLD_LIBRARY_PATH. Do I need code-signing ?
greetings ascorbin
-
Hi ascorbin,
I'm jumping here since Andreas will be off for a few weeks.
One of the major differences in dylib vs dll is install name. The install name is a path baked into the dynamic library that says where to find the library at runtime.
It does not matter where you copy your dylibs, It will always point to old path (except without changing install name) and you can query for the original search path (install name) by using command:
otool -L a.dylib
From your description it's pretty likely that your library install name points somewhere else or that is simply not set.
Might you try, in the library project, to set the Installation Directory to@rpath
, recompile and copy the .dylib in<plugin>/res/libs/osx
? This will set the install name to point to the Runtime Search Path.
If you're not getting out of trouble, just notify me again and I'll try to come asap with a simple example showing how to set things properly.Best, Riccardo
-
Hi Riccardo
Thank you for this hint. The trouble is that it is a precompiled 3rdParty-Dylib which i can‘t compile by myself.
Greetings ascorbin
-
Hi ascorbin,
I see the point. Well in this case I strongly suggest you to google around for
install_name_tool
and see (e.g. here) how helpful it can be with regard to dylib handling.What I suggest is:
- make a backup copy of your dylib
- execute in a terminal
install_name_tool -id "@loader_path/res/libs/osx/<yourlib>.dylib" <path to your c4d plugin>/res/libs/osx/<yourlib>.dylib
- rebuild your plugin to be sure that the referenced .dylib informs your plugins about the install name update
This should update the install name of your dylib, inform your plugin about the path to look for and, in the end, have your plugin properly loading the dynamic library.
Let me know, Riccardo.