Vincent Berthiaume
Vincent Berthiaume

Reputation: 87

How to use an external dll when building a vst under windows

I'm trying to use the Leap motion sdk with a JUCE vst plugin under Windows 10 x64.

I have setup my project exactly like this, and made sure that Leap.dll was in my output, VstPlugins directory. However my DAW (Reaper) cannot detect/open my plugin's dll. I have also tried to put my x86 Leap.dll in C:\Windows\System32 (and my x64 version in C:\Windows\SysWOW64), and tried to regsvr32 them, only to be told the DLLRegistryServer entry point cannot be found.

When I comment everything related to the Leap sdk, my plugin is detected in Reaper and everything else works, and on Mac OSX I am able to use the Leap as well, so it seems my problem is really that my Windows system does not know it has to use Leap.dll with my plugin's dll. How does one go about doing this?

Upvotes: 0

Views: 1217

Answers (1)

Ehsan Enayati
Ehsan Enayati

Reputation: 309

If it is a dynamic library you do not need to include it in your project. All you need is to copy the file onto user's machine in a specific folder and then in your plugin code add something like this:

DynamicLibrary dynLib;
bool loaded = dynLib.open("DYNAMIC_LIBRARY_FULL_PATH");
if(loaded)
{
    FUNCTIONTEMPLATE functiontemplate = (FUNCTIONTEMPLATE) dynLib.getFunction("functionName");
    char *input;
    int output = functiontemplate (input);
}

Of course if you did not write the dynamic library yourself, then you need something like dependency walker to check inside the dll and find the function declaration or read the documentation from whoever wrote the dll. Anyway, you need to know the exact function declaration format and create a pointer to that. Imagine it is function that accepts char* as input and returns int as output, then you need to have a line like this on top of your .cpp or .c code:

typedef int (*FUNCTIONTEMPLATE) (char *);

Upvotes: 1

Related Questions