How to link libraries into a node with the Vuo SDK?

Hello, I try to import 3rd party PvAPI libraries (static or dynamic) with no luck… vuo.leap/kinect/syphon doesn’t show me how exactly can I link shared libraries in .vuonode. I luckily imported PvApi.h and compiled vuonode with success, but when I try to exec any function from shared library I get error thrown by Vuo about something wrong with node. Without using library’s function there is no error.

I thing the issue is in the .pro file… NODE_LIBRARY_INCLUDEPATH is set to proper library path, but I don’t know is it everything to import 3rd party libraries to vuonode… It is needed to include .dylib file it in node set?

Cheers, Teo

Here are some more information about my work.
I tried to build node with library module wrapping shared PvApi lib on top of customType example from 1.2.1 SDK. I’ve attached compressed sources - everything builds succcessfully, but nothing changes; Vuo starts normally but when my node starts up - this error occurs:

Node outdated or broken — One or more nodes in this composition can’t be used by this version of Vuo. Make sure you’re using the latest version of all the extra Vuo nodes you’ve installed:
• example.customType.greet

Could someone take a look at this? Thanks for help!
Teo

customType-pvapi.zip (330 KB)

Ok, so here it comes: I successfully linked shared library with node - there’s no need to build a library module, only you have to place "dependencies": [ <libs> ] in VuoModuleMetadata section of node source AND #include library header files. Another thing is to copy library files to Vuo Modules Folder (where all custom .vuonode files exist).

But it works for me only with static libs. Somewhere on api.vuo.org it is written that you have to put dependencies without “lib” and extension - it’s true since Vuo resolves filenames of libs automatically. However, Vuo doesn’t open .dylib files for me and error occurs. When I use .a static libs everything works fine.

Now I’m going to write some code…

Here you can find more information:
Managing Dependencies  

Dynamic libraries are kind of a pain, from the point of view of a developer trying to link them into their code. So you might want to stick to static libraries. But if you really want dylibs…

The difficulty with dylibs is install names. Inside the dylib file is stored its own path and the paths to its dependencies. When you move the dylib file to the Modules folder, you have to update those stored paths. This requires running some commands in Terminal.

As an example, the Kinect node depends on libfreenect.dylib. I can see this library’s install name and the install names of its dependencies by running the otool -L command, like this:

$ otool -L /usr/local/Cellar/libfreenect/0.2.0/lib/libfreenect.dylib 
/usr/local/Cellar/libfreenect/0.2.0/lib/libfreenect.dylib:
	libfreenect.0.1.dylib (compatibility version 0.1.0, current version 0.1.2)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.44.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
	/usr/local/Cellar/libusb/1.0.9/lib/libusb-1.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

After copying libfreenect.dylib to the Modules folder, which I’ll abbreviate as $$MODULES_DEST_DIR below, I can change its install name and the install name of the libusb dependency, which is specific to my computer, like this:

install_name_tool -id "@rpath/$$MODULES_DEST_DIR/libfreenect.dylib" "$$MODULES_DEST_DIR/libfreenect.dylib"
install_name_tool -change "/usr/local/Cellar/libusb/1.0.9/lib/libusb-1.0.0.dylib" "@rpath/$$MODULES_DEST_DIR/libusb.dylib" "$$MODULES_DEST_DIR/libfreenect.dylib"

(This example comes from the file framework/framework.pro in the Vuo source code.)