I’m testing out whether I can use an externally compiled .dll in a cpp custom operator, but the instructions are confusing to me Custom Operators | Derivative
If the plugin requires linking with other .dylibs or frameworks, they should be located next to the plugin.@loader_path/
prefix should be used to reference the dependencies. They can be changed with the macOS toolinstall_name_tool
, and the current dependency paths can be inspected with the command otool -L yourlib.dylib
I’m using xcode and I’ve been able to successfully build the plugin based on the example CHOP CustomOperatorSamples/CHOP/BasicFilterCHOP at main · TouchDesigner/CustomOperatorSamples · GitHub. My library exposes a function called
double func1() that I’m bringing in via the inclusion of the .dylib that contains the compiled library and the two header files I used.
Here I’m showing the line where I’m using the
Since I’m using a dynamic library I have set the project settings to update the
library search path and the
runtime search path and added the @executable_path to the install name so that it will look in it’s current folder for the dynamic library files.
When I select
product -> archive the build is successful and I get a window asking to distribute the contents. I select build product and it lets me select an output path for a new folder. Once I export I can go into that folder and see that the plugin has been created. According to the custom operator page I need to copy the dylib to be right there next to it so that’s the other contents in the directory.
In TD I use a customcpp operator but it shows this error when I try to load
I know that often times the paths are wrong for linking and so I decided to explore the contents of the plugin package and use
otool on the executable to see where it’s trying to link my dylib.
so it thinks its supposed to find the dylib at
/libtest_dylib.dylib. Unfortunate library naming aside, this isn’t where the library is so I
-change the path for that. There’s a couple lines that warn me this will invalidate code signature which seems like a bad thing, but I don’t know what else to try.
TD appears to not like this invalidated code signature stuff because as soon as I try to load the plugin now, the program crashes.
So, I’m having a lot more trouble than a 1 paragraph section of the instructions seems like it covers, can anyone weigh in on how to do this fairly important task?
If it’s helpful I’m developing for an m1 mac.