Build OF as a shared library in macOS

I’m trying to build OF as a shared library (.so) in macOS.

I added the following to my app’s config.make file.

APPNAME = myApp.so

PROJECT_LDFLAGS = -rdynamic -shared -undefined dynamic_lookup

PROJECT_OPTIMIZATION_CFLAGS_RELEASE = -O3

But when I build the project using make, it actually generates an Application file myApp.so.app which is not a shared library.

How can I properly build OF as a shared library in macOS?

Removing @mv $(TARGET) bin/$(BIN_NAME).app/Contents/MacOS from OF/libs/openFrameworksCompiled/project/osx/config.osx.default.mk file prevented the shared library being renamed to an .app file.

Is it possible to do the same thing through project’s config.make file?

I would suggest just using the Xcode project located at:
openFrameworks/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj

You could change the library type from static library to dynamic library in the target settings ( .dylib not .so )

You would of course have to handle the linking of all the dependent libraries ( freetype, glfw etc ), but that should build OF as a dylib.

1 Like