Linking static libraries in my plugin

I’m just starting with writing VCV Rack plugins.

And I want to bring in some C++ code I already used in other projects, into my plugin.

What’s the best way to do that?

I tried making it as a Linux static library, putting a symlink to a directory containing it, under the src directory where I’m developing my plugin code, and adding the following to the Makefile

CXXFLAGS += Lmylibpath
LIBS = mylibname

and including in my header file

#include "mylib/myheader.hpp"

Calling make in the plugin directory seems to work OK.

But when I make run in the main Rack directory to run the whole of Rack including my plugins (which is how I normally see them running), Rack fails to load with

Failed to load library ./plugins/MyPlugin/ ./plugins/MyPlugin/ undefined symbol: _ZN3mylib12PhaseCounter5startEff

The PhaseCounter object comes from my library. And is in its own namespace. All of which I seem to be handling OK in the plugin itself. It does seem to compile without error.

But Rack doesn’t seem to be able to see it.

Anyone have any ideas why?

Or maybe it would just be simpler to put all the source of my library into a subdirectory.

If so, how would I do that? (Ie. modify the Makefile in the plugins/myplugin to be able to compile and link hpp / cpp files from a subdirectory of plugins/myplugin/src)?

Just use

OBJECTS += path/to/libwhatever.a

If you want to submit to the Plugin Manager, you need to make your library build on all platforms with make dep. See Fundamental’s Makefile for an example.

Cool. That’s what I was looking for.