Rack: code 126 when loading plugin.dll

Created on 1 May 2020  路  13Comments  路  Source: VCVRack/Rack

Details

Operating system and version: Windows 10, 64 bit
Rack version (vX.Y.Z): 1.1.6
GCC Version: 9.2.0

Summary

When I load my plugin.dll from the Rack installed with installer, I get [0.046 warn src/plugin.cpp:158] Could not load plugin C:\Users\Nowhk\DOCUME~1/Rack/plugins-v1/test: Failed to load library C:\Users\Nowhk\DOCUME~1/Rack/plugins-v1/test/plugin.dll: code 126

Instead, if I build and run using the Rack I've compiled with sources, it works correct.
This only happens when I use an external library called SoundTouch.

I static link it with:
LDFLAGS += -llibSoundTouch

Code

Here's the basic code of the module, that works on both Rack compiled by me or official Rack installed by installer:

#include "plugin.hpp"

struct Default : Module {
    enum ParamIds {
        NUM_PARAMS
    };
    enum InputIds {
        NUM_INPUTS
    };
    enum OutputIds {
        NUM_OUTPUTS
    };
    enum LightIds {
        NUM_LIGHTS
    };

    Default() {
        config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
    }

    void process(const ProcessArgs &args) override {
    }
};

struct DefaultWidget : ModuleWidget {
    DefaultWidget(Default *module) {
        setModule(module);

        // background
        setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Default.svg")));
    }
};

Model *modelDefault = createModel<Default, DefaultWidget>("Default");

If now I include #include <soundtouch/SoundTouch.h> and I simply create an instance soundtouch::SoundTouch mSoundTouch;, on Rack installed by installer don't load plugin.dll, and log that error. Instead, on Rack compiled by myself (on my machine) it works without any problems.

Any clues? If you need more info, please let me know.

All 13 comments

I need more information about how you're building SoundTouch and the complete list of additional flags in your Makefile. Simply adding -llibSoundTouch to LDFLAGS won't work. The linker needs to know the location of the static library.

I got the build of SoundTouch using pacman -S mingw-w64-x86_64-soundtouch.
It include the pre-compiled static version of the library. I don't build it on my own.

So include the header and add that flag is the only thing it needs.

Here's the g++ command:

g++ -Isrc/ -std=c++11 -Wsuggest-override   -fPIC -IC:\repos\Rack/include -IC:\repos\Rack/dep/include -MMD -MP -g -O3 -march=nocona -funsafe-math-optimizations -Wall -Wextra -Wno-unused-parameter -DARCH_WIN -D_USE_MATH_DEFINES  -c -o build/src/modules/Default.cpp.o src/modules/Default.cpp
g++ -o plugin.dll build/src/plugin.cpp.o build/src/modules/Default.cpp.o -llibSoundTouch -shared -LC:\repos\Rack -lRack 

You need to build the library from source in your plugin repository.

Why do I need to "build it"?

I static link the library in my target plugin.
And it works just fine when I load my plugin.dll using the compiled version of Rack.

Why it doesn't work using the Rack created by your installer? I believe the source are the same...

That the issue, isn't it?

You'll need to build SoundTouch on Mac/Linux as well, so why not include it in your plugin build system?

I'm just testing the library, to see if it fit well for my needed. Once I choose it, I will for sure build it from scratch.

But right now thats not the issue. Its to understand why plugin don't load using your rack Build :(

Do you need my build version of soundtouch to resolve this problem?

Are you sure you are linking to the static version? Did you try adding -Wl,-Bstatic?
And are you sure SoundTouch is not linked to anything else dynamically which needs to be found when plugin.dll is loading?

Are you sure you are linking to the static version? Did you try adding -Wl,-Bstatic?
And are you sure SoundTouch is not linked to anything else dynamically which needs to be found when plugin.dll is loading?
Sure man, else it won't never loading, neither on the Rack compiled by sources.

As said, when I run Rack compiled, the plugin load without any problems.

I try those -Wl,-Bstatic though, and let you know (give me some hours).

Ok I think I got it, forcing the library to be static: LDFLAGS += -static -l:libSoundTouch.a.
I close the issue, thanks for the tip magic @stoermelder ;)

-static links everything statically. You don't want to link system libraries and libRack statically. I'm not even sure how it's possible that it "works" when you specify -static.

That's because it switch between static and shared in the sequence: .... -static -l:libSoundTouch.a -shared -LC:\repos\Rack -lRack
I can remove it :) It still works.

Oh okay, if you switch back to -shared with then it should work.
However, it won't work for Mac/Linux because the static library is not included on all systems that may build the plugin.

I know, but as I said, if I decide to use the lib, I'll build it from sources.
So it will work for Win/Max/Linux ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

synthi picture synthi  路  4Comments

polyclash picture polyclash  路  3Comments

vogelscheiss picture vogelscheiss  路  5Comments

oblivionratula picture oblivionratula  路  7Comments

gogobanziibaby picture gogobanziibaby  路  4Comments