This is WIP as gcc 5
might have changed linking behavior.
In particular, it might now be necessary to pass the --export-dynamic
flag to the linker by adding PROJECT_LDFLAGS += -Wl,--export-dynamic
to config.make
. This might cause errors with the clang
compiler, so further investigation is due.
- run
compile-libs.sh -f
- in another terminal,
make
andmake run
the application - edit
src/DynamicLibs/Libs/Stuff.cpp
- e.g. thedraw
function - and save it to see live updates!
check out diagrams/overview.svg
to understand the basic architecture:
- application and libraries communicate via the interfaces found in
src/DynamicLibs/Interfaces
. - the libraries implement these interfaces (and add extra stuff as needed).
- library source files found in
src/DynamicLibs/Libs
are automatically compiled into thebin/data
folder by thecompile-libs.sh
shell script. - that same script signals the application to reload the libraries on successful compilation.
the
DynamicLibs
class takes care of this for you.
peek at diagrams/diy.svg
to add your own libraries:
- write a suitable interface header file in
src/DynamicLibs/Interfaces
- add a member variable of the interface type to the
MyLibs
class found insrc/DynamicLibs
and initialize it inside theMyLibs::initLibs
function. - write the implementation in
src/DynamicLibs/Libs
; implement the interface and providecreate
anddestroy
functions withextern "C"
linkage.
- the
compile-libs.sh
script assumes either a 64-bit linux runninggcc
(tested with 4.9.2) or mac os x (tested on 10.11) runningclang
. src/DynamicLibs/Libs
needs to be excluded from compilation insideconfig.make
- to make this run on Linux, you will need to recompile oF with the
-fPIC
compiler flag; apply the0001-add-fPIC-flag-to-compile.core.mk.patch
to the openFrameworks-repository to set the flag, thenmake clean
andmake
your openFrameworks (from insidelibs/openFrameworksCompiled/project
)