and libs for OSX

I am not sure if I missed something simple but I would like to make an addon I am working on include dyld files that are installed via homebrew (obviously I am on OSX). I want to add some but not all of the libs in a folder (this should be in the same place for every brew install). Is there a way to specify this in the for the project generator? I see there is an option for linux with ADDON_PKG_CONFIG_LIBRARIES but I don’t see how I can do this for OSX.
Is this possible?

1 Like

is a great piece of mechanics which allows any addon in the make system to include libraries and external codes to your own on any platform. linux, arm, android, ios, osx, dos, …

simply configure accordingly for each platform, and libs & other code are loaded for compilation.

if you want to include a library like for example libname.dylib you can use ADDON_LDFLAGS=-lname

Cheers, sorry for asking simple questions but I still dont make this work:

For multiple libs should I use this format:

ADDON_LDFLAGS = libpcl_keypoints.1.9.1.dylib 
ADDON_LDFLAGS += libpcl_ml.1.9.1.dylib 
ADDON_LDFLAGS += libpcl_octree.1.9.1.dylib 
ADDON_LDFLAGS += libpcl_outofcore.1.9.1.dylib 

Also how do I specify the path of the libs?

Should I add it like this for each lib?
ADDON_LDFLAGS = /usr/local/Cellar/pcl/1.9.1_4/lib/libpcl_keypoints.1.9.1.dylib
(this does not seem to work for me)

I also tried to add:
ADDON_SOURCES += /usr/local/Cellar/pcl/1.9.1_4/lib/
As this is the folder where the libs I want to link are, but it also does not pick them up.

Lastly, is there a way to alter user defined parameters in xcode with the
For this project I need to change:

HEADER_BOOST ="$(OF_PATH)/libs/boost/include"
HEADER_BOOST = /usr/local/Cellar/boost/1.72.0/include

It is pretty simple to do it manually, but it would be cool if the PG did the work for me.


no, you don’t need to specify the full file name, you need to pass the -l flag to the linker with the actual name of the library. That is, minus the lib prefix and the extension so something like:

ADDON_LDFLAGS = -lpcl_keypoints.1.9.1 
ADDON_LDFLAGS += -lpcl_ml.1.9.1
ADDON_LDFLAGS += -lpcl_octree.1.9.1
ADDON_LDFLAGS += -lpcl_outofcore.1.9.1

if this libraries are in the system they should be in the default includes path so that should be enough but in case it’s not you can specify a libraries search path with the -L flag as in:

ADDON_LDFLAGS += -L /usr/local/Cellar/pcl/1.9.1_4/lib/

Ok, this makes sense, but even when specifying the path I get
ld: library not found for -libpcl_apps.1.9.1

I’m so glad this thread is archived in the forum! It has helped me a few times over the years.

I wanted to link to some dynamic lib files in an addon. The .dylib files reside in the /addons folder at the location described by the flags, and are not in the /Cellar folder of Homebrew. The linker found the libs if I added both of the following lines to

    ADDON_LDFLAGS +=  -rpath /Users/chilina/oF0.11.2/addons/ofxTbb/libs/ofxTbb/lib/
    ADDON_LDFLAGS += -L /Users/chilina/oF0.11.2/addons/ofxTbb/libs/ofxTbb/lib/

I’m using macOS Big Sur 11.6 and Xcode 13.0. It took me a bit to figure this out, and how the project generator sets up the Build Settings in Xcode accordingly. So I’m positing it here in case it helps; this may not be the best place for this post though.

1 Like