Plugin system addon for openframeworks : linker and makefile issue

Hi

I’m trying to make an openframeworks addon for a plugin system based on Pluma (http://pluma-framework.sourceforge.net/).
For now this I am testing this on Linux 64Bit with of 0.90.
But I’m in trouble with compilation and makefiles.
Everything works well with pluma integration. And for core modules integration everything is fine. The problems appear when I try to load plugins with openframeworks dependencies.
I have to link the test plugin with openframeworks core and addons libs. And I’m in trouble with this.
It compiles But when I launch the app I have the error (dlsym error) : undefined symbol: _ZTI5ofLog.
Which means that the linkage has been wrong.
To compile the plugin I have set up a module.mk makefile and I include it in the project Makefile

################################################################################
# CONFIGURE MODULE MAKEFILE
#   module.mk define rules to compile the ofxPluma module
#    this file is included in the project makefile after the line : 
#
#    include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
#
################################################################################

ifndef PROJECT_ADDONS_INCLUDES
    include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk
    include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/config.addons.mk
endif

MODULE_ADDONS_INCLUDES = $(addprefix -I, $(PROJECT_ADDONS_INCLUDES))
MODULE_CFLAGS = -export-dynamic -fPIC -Wall -Wextra -O2 -g
MODULE_LDFLAGS = -shared 
MODULE_TARGET_LIB = MyModule.so # target lib
MODULE_ADDON_STATIC_LIBRARIES = $(ADDON_STATIC_LIBRARIES)
MODULE_ADDON_SHARED_LIBRARIES = $(ADDON_SHARED_LIBRARIES)
MODULE_ADDON_LIBS = $(MODULE_ADDON_STATIC_LIBRARIES)
MODULE_ADDON_LIBS += $(MODULE_ADDON_SHARED_LIBRARIES) 
MODULE_CORE_LIB = $(OF_CORE_LIB_PATH)/libopenFrameworksDebug.a


MODULE_SRCS = MyModule.cpp
MODULE_OBJS = $(SRCS:.c=.o)
MODULES_DEST = bin/data/.modules/Core

.PHONY: moduleHelp

moduleHelp:
    @echo 
    @echo ofxPluma test plugin integration
    @echo Compilling module : $(MODULE_TARGET_LIB)
    @echo MODULE_CFLAGS : $(MODULE_CFLAGS) 
    @echo MODULE_LDFLAGS : $(MODULE_LDFLAGS) 
    @echo LDFLAGS : $(LDFLAGS)  
    @echo OPTIMIZATION_CFLAGS : $(OPTIMIZATION_CFLAGS) 
    @echo CXXFLAGS : $(CFLAGS) 
    @echo CXXFLAGS : $(CXXFLAGS) 
    @echo OF_CORE_INCLUDES_CFLAGS : $(OF_CORE_INCLUDES_CFLAGS) 
    @echo MODULE_ADONS_INCLUDES : $(MODULE_ADDONS_INCLUDES)    
    @echo MODULE_SRCS : src/$(MODULE_SRCS)  
    @echo MODULE_CORE_LIB : $(MODULE_CORE_LIB)  
    @echo OUTPUT : -o $(MODULES_DEST)/$@ 
    


$(MODULE_TARGET_LIB): 
    @echo 'compiling modules lib'
    @echo CORE LDFLAGES $(LDFLAGS)
    @mkdir -p $(MODULES_DEST)
    $(CXX) $(MODULE_CFLAGS) $(MODULE_LDFLAGS) $(LDFLAGS)  $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(OF_CORE_INCLUDES_CFLAGS) $(MODULE_ADDONS_INCLUDES)   src/$(MODULE_SRCS) -o $(MODULES_DEST)/$@ 

When I try to compile and link the module with openframeworks lib it fails. What am I missing ?
What is for you the better way to achieve compilation with openframeworks makefiles for outputting shared libs ?

Thanks.

Hello everybody,

I’ve tried to recompile openframeworks with PIC (adding -fPIC to PLATFORM_CFLAGS in config.linux.common.mk) and to add openframworks core lib ( openframeworks.a ) after module source in the module.mk file. I know this is not the good way of doing it but is there another way ?
Now the linker complains with the core dependencies libs (libkiss.a static lib in the openframeworksCompiled folder for example).
So I tried to link this libs by adding the flag -Wl,--whole-archive and including the same way as I done it for the core openframeworks lib but the compiler still complains.

Is there a solution to compile openframeworks as a shared lib ?
If it’s possible maybe itis the solution :

  • compile openframeworks as a shared lib
  • link it against the main app.
  • link all the plugins and core modules against this shared openframeworks lib.

Hi, please see the below post of @arturo about how to compile openFrameworks as a shared library. (Of course you should change the platform_os variable to your target platform)

thank you for this link. I will try it.