Could openframeworks projects link with external shared libraries (Linux)

Hi All,

As a new comer to openframeworks projects I want to know that could I include some external Linux shared library header files into a “.cpp” file of an openframeworks project and then compile the “.cpp” file and link it to the external shared library’s “.so” file ?

I know that I could add “USER_CFLAGS = -I/path/to/external_shared_library/header.h” and add “USER_LIBS = -lexternal_shared_library” in “config.make”. But how could I add a flag for openframeworks to search for the location of the external shared library in linking process, e.g. “-L/path/to/external_shared_library” and how could openframeworks finds the external shared library when I run the compiled program (assume that the external shared library is not in the standard locations such as /usr/lib, /usr/local/lib) ?

openframeworks would be even more interesting if it could link to the world of external shared libraries.

Thanks for any suggestion.

Regards
Lawrence

you can actually link to dynamic libraries in the same way as static, just add the library to USER_LIBS

If they are in the standard location, then if the library is something like:

  
libsomelib.so  

you can just link to it addin:

  
-lsomelib  

if it’s not you can use:

  
-lsomelib  
-LpathToLib  

or just the whole path:

  
pathToLib/libsomelib.so  

then the program needs to know where to find the library when it runs, for that in LD_FLAGS add:

  
-Wl,-rpath=pathToLib  

1 Like

Thanks a lot, arturo.