Example #1
0
void testApp::loadDylib(string file) {
	mutex->lock();
	if(livecodeLib!=NULL) {
		dlclose(livecodeLib);
		delete eff;
		livecodeLib = NULL;
	}
	
	
	livecodeLib = dlopen(file.c_str(), RTLD_LAZY);
	
	if (livecodeLib == NULL) {
		// report error ...
		printf("Error: No dice loading %s\n", file.c_str());
	} else {
		// use the result in a call to dlsym
		printf("Success loading\n");
		
		
		void *ptrFunc = dlsym(livecodeLib, "getAudioEffect");
		if(ptrFunc!=NULL) {
			
			AudioEffect *e = ((AudioEffect *(*)())ptrFunc)();
			e->setup();
			doGui(e);
			eff = e;
			
		} else {
			printf("Couldn't find the getAudioEffect() function\n");
		}
	}
	mutex->unlock();
	
}