Including library fails

Hi

When using INCLUDEPATH xxx in the .pro file of a node set to include an external header based library (Asio C++ Library) I get “File not found” both with relative and absolute paths after running Qmake. Typing #include "… results in auto-complete only listing the folders/files in the source directory. I guess this is a compiler issue after some testing and reading, but I’m not sure where to go from here. Is it possible for someone from team Vuo to shed some light on using external libraries and gotcha’s that might occur?

1 Like

See the attached example. I used the ‘stateless’ example in the Vuo SDK (/Library/Developer/Vuo/example/node/stateless) as a starting point.

To build and install the node class:

  • cd asio-test
  • mkdir build
  • cd build
  • cmake ..
  • make

To answer your original question of how to include an external header-based library — that much was possible by:

  • placing asio.hpp and the asio folder in the same folder as the node class,
  • adding #include "asio.hpp" to the node class (jstrecker.asio.test.c), and
  • adding -I .. to the vuo-compile command in CMakeLists.txt.

However, it took a few more steps to get the node class to actually compile. Because the Asio library uses C++ exceptions, there’s a flag you have to pass to clang (-fexceptions) or else you get compile errors. But there’s currently no way to pass that flag through to clang when you run vuo-compile. So I moved the code that references Asio from jstrecker.asio.test.c to AsioWrapper.cc, and added stuff to CMakeLists.txt to compile AsioWrapper.cc with clang.

asio-test.zip (1.13 MB)

2 Likes

Thanks a bunch Jaymie! A lot of good learning material there :D

Maybe I’ll even manage to make something useful!

2 Likes

Side note: I recently “upgraded” to macos 10.15, and so also xcode 12.1. Because of this, the default MacOs SDK is 10.15. This won’t compile with that, but earlier SDKs can be found here: https://github.com/phracker/MacOSX-SDKs/releases. Download the required one (10.10) and place it in the folder specified in the CMakeLists.txt and it will compile.

2 Likes

Good to know. All these info fit well in the An advanced tutorial on plugin developing FQ.  

2 Likes

Or the official macOS 10.10 SDK from Apple is available by downloading Xcode 6.4 on https://developer.apple.com/download/more/

(Fortunately, the macOS 10.10 SDK should no longer be necessary with the upcoming Vuo 2.3.0 release, since it will use a newer version of LLVM.)

After trying out a few things, I now manage to compile a node successfully. However I still have an issue when I try to run a composition with the external library. I guess my understanding of how it works still isn’t quite there. The error message I get inside Vuo is:

Node broken or outdated — 
Undefined symbols for architecture x86_64:
  "__Z12VuoData_makexPh", referenced from:
      _receiveUDPMessage in composite-Ys4j2y-nIfWvb.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

From searching for the issue, it seems like there is something wrong with the build settings, but I don’t understand where that lies.

Attaching the source and nodes if you find the time to look at it.

asio_not_working.zip (1.42 MB)

In AsioWrapper.h, try moving #include "VuoData.h" inside the extern "C" { … }.

(The clue is that it’s complaining about __Z12VuoData_makexPh, a mangled C++ symbol, instead of VuoData_make.)

1 Like

Ah! Thank you, now it works! Or Vuo side of it at least, now it’s only a matter of understanding the rest :sweat_smile:

1 Like