LoadLibrary / CFBundleLoadExecutable (VST Hosting)


#1

Hi Jules,

I’m writing some basic stuff for a VST host.

Question is simple: do u know how if is possible to load a library and get entry point for a function (from a dll in Win32, from a bundle in mac I guess) in a portable manner with JUCE?.

I mean, tried to use the following code (part of VSTSDK2.4 ‘minihost’):

[code]

// win 32 load library
module=LoadLibrary(fileName);



CFStringRef fileNameString = CFStringCreateWithCString (NULL, fileName, kCFStringEncodingUTF8);

if(fileNameString==0)
	return false;

CFURLRef url=CFURLCreateWithFileSystemPath(NULL,fileNameString,kCFURLPOSIXPathStyle,false);
CFRelease(fileNameString);

if(url==0)
	return false;

module=CFBundleCreate(NULL,url);
CFRelease(url);

if(module && CFBundleLoadExecutable((CFBundleRef)module)==false)
	return false;

But as soon as I include “windows.h” at top of my cpp file, I get a lot of errors (looks like include windows.h along JUCE is not possible).

Any alternative?

A crossplatform library loader would be nice.

Thanks for your time.


#2

Just make sure you include juce.h after windows.h and it’ll be fine.

A cross-platform loader’s tricky because loading a VST requires various hacks, and it’s not really generic enough to go into the library.


#3

You can’t do it with JUCE and its not trivial on the Mac but you can find a working code here (Mach-o plugins only, not CFM):

http://achitophelconsulting.com/

download source code for version 1.1 and its all there


#4