Dynamic library loading code disapeared


Hi Jules,

These functions disapeared in the last big changes of the mac platform specific code. Is there a reason why you moved them, or are we the only ones to use it ? : )

// in mac platform specific code
#include "../../../src/juce_core/misc/juce_PlatformUtilities.h"
#include <dlfcn.h>

void* PlatformUtilities::loadDynamicLibrary (const String& name)
  {return dlopen ((const char*) name, RTLD_GLOBAL | RTLD_NOW);}
void PlatformUtilities::freeDynamicLibrary (void* handle)
void* PlatformUtilities::getProcedureEntryPoint (void* libraryHandle, const String& procedureName)
  {return dlsym (libraryHandle, (const char*)procedureName);}


I think they were old carbon functions, and the cocoa equivalent didn’t work in the same way. I don’t think there’s really a cross-platform function that fits…


These are c calls, but they are not supported by windows. You can call them directly or you can put them in a header file and include that header files in source files where you need those calls.

Something like this.

#if WIN32
	#define DYNAMIC_LIBRARY_LOAD(X) ::LoadLibrary(X)
	#define DYNAMIC_LIBRARY_FREE ::FreeLibrary
	#define DYNAMIC_LIBRARY_LOAD_PROC ::GetProcAddress
	#define DYNAMIC_LIBRARY_FREE dlclose

You are not the only one to use it. I use it for loading couple of dll’s on mac and pc without juce.


well, I don’t know anything about cocoa, but we were just missing these functions on MacOS to load some dynamic libraries.
These functions are now inside a

code block so I was wandering why and if you plan to replace them …

For now I just commented out the #if and use the implementation that I gave in my first post.


The problem is that on the mac there are at least 3 different ways you could load different kinds of library/bundle, and in cocoa you no longer have a way of getting function pointers from it - it’s all class-based instead. So really, I can’t see much point in trying to make a cross-platform way of doing it!