Can I change empty example xcode project output to .dylib?

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.

Hi, so you are trying to compile OF as dylib and open it from your other application through dlopen?

This is how to build openFrameworks as dylib in Mac OSX.

  1. Create a new project using a project generator.

  2. Open the generated project with Xcode. In Xcode, go to Editor - Add Target…

  3. Select OS X - Framework & Library - Library and click next.

  4. Type in the library name, set Framework: None (Plain C/C++ Library), Type: Dynamic and click Finish.

  5. Select the newly created target - build settings, Deployment - Installation Directory, and Type the path where you want to create a .dylib file.

  6. Find Deployment - Installation Build Product Location, type in ‘/’

  7. Find Build Locations - Per-configuration Build Product Path, type in $(INSTALL_PATH)

  8. go to Target - Build Phases,
    Target Dependencies -> add OpenFrameworks(openFrameworksLib)
    Compile Sources -> add main.cpp, ofApp.cpp
    Link Binary With Libraries -> add openFrameworksDebug.a
    Headers -> add ofApp.h

  9. Set build target to the current one

  10. Click Product - Build (Command + Build) and see if the dylib file gets generated in the installation path.

  11. 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.

  12. 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");
    return 0;
return 0;


  1. 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)

  2. Now, in your host xCode project, select Products - file, right click and select Show in Finder

  3. Paste libfmodex.dylib file into the folder

  4. Now run the project and you will see a window created from the opened dylib 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. :slight_smile:
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

1 Like

Thank you for your answer :slight_smile: