I’d like to use ofxOsc in a non OF project, so my idea is to create a dylib in xcode, then link to it at run time. I’d like to take empty example, add ofxOsc, change settings to output as dylib, remove the source files, then add an interface header and implementation cpp. Can that be done?
I’ve tried adding openframeworks lib to a new non OF project and added ofxOsc but it just won’t compile, it won’t find ofMain.h as I assume it’s not getting the correct header search paths.
edit: I tried adding a new target that links to OF and compiles all added addon files, not quite working yet but I’m sure it will, the test project isn’t finding the dylib even though it’s there in the output folder, must be a mismatch of settings.
Now close the project and lets create a host application project to open the .dylib file.
Open Xcode and select Create a new Xcode project.
Select OS X - Command Line Tool - click next, type in the project name and click create.
Type in the following code in main.cpp to open the dylib file from the installation path.
(Make sure to correct the installation path)
#include < iostream > #include < dlfcn.h >
int main(int argc, const char * argv[]) {
void* handle;
typedef void (*func_t)();
handle = dlopen("/Users/cuinjune/Desktop/myLib_build/libmyLibDylib.dylib", RTLD_LAZY);
if (!handle) {
printf("failed to open the library\n");
return 0;
}
func_t mainFunc = (func_t) dlsym(handle, "main");
if (!mainFunc) {
printf("failed to find main method\n");
dlclose(handle);
return 0;
}
mainFunc();
return 0;
}
Now go to openFrameworks/libs/fmodex/lib/osx and find libfmodex.dylib file and copy it.
(This file has to be located in the same folder as the host application build file)
thank you very much for that, I had done a fair bit of it already but it wasnt working as I hadn’t copied over the fmod library. I have no intention of using it but it turns out if the program cant find one dylib then it won’t find any others. all working now, now i can use an openframeworks project in a vst, which is nice.
You’re welcome. I’m glad I could help.
By the way, is it possible to create a VST or AU using openFrameworks?
Can OF be used for creating VST’s GUI and processing audio?
I would appreciate if you could share some knowledge regarding it.
I dont think it would be, maybe its the wrong tool for the job. JUCE is set up to do that very well. I don’t think OF is good for GUI or audio, with vst’s all you get is the data coming through in a callback (afaik) and there wouldnt be anything contained in OF that could do anything with it directly. FMOD works with it’s own events and rtaudio just streams to devices. maybe there would be a way of opening an opengl context in the vst window and passing it to OF loaded as a lib to do the gui.
if it were me I would just code the vst/plugin raw. maybe future work for OF would be to export as VST/AU/AAX