I am trying to build a plugin based application in C++.
I have two targets - base and plugin.
This is a portion of my CMakeLists.txt that does the main work
# Executables
# build plugin
file (GLOB SRCP "plugin/*.?pp")
include_directories(plugin/)
MESSAGE ( STATUS "SRC: " "${SRCP}" )
add_library(testplugin MODULE ${SRCP} )
add_dependencies( testplugin ${DEPS_TARGETS})
#target_link_libraries( testplugin dlib::dlib )
#build main
file( GLOB SRC "*.?pp" )
message( STATUS "SRC: " "${SRC}" )
add_executable( exec ${SRC} )
add_dependencies( exec ${DEPS_TARGETS})
target_link_libraries( exec dlib::dlib )
It builds successfully but when I try to load the plugin, it fails with this error
Error: Cannot load library: libtestplugin.so: undefined symbol: _ZN4dlib6loggerD1Ev
That symbol corresponds to a statement in the plugin dlib::logger dlog("main.abstract_cnn");
dlib is a static library which I am using in both the base and the plugin. I link this library to the base application but I don't know how to link it to a library/module? Won't the base application pass on the symbols to the plugin? What can I do in this situation?
I would also like a cross-platform solution. Mainly linux+windows.
Can anyone advise? Please?
How I am Loading I am using a library called Libsourcey which has a module called pluga for easy loading. My program is the basic test program given here pluga. It works for me, but when I try to include a 3rd party library I am stuck.
If anyone could point to resources that explain how to use 3rd party libraries in plugins, it would be great!
target_link_librariesthat you commented out for the shared library, what happens if you actually let CMake run it? - Some programmer dude/usr/bin/ld: deps_build/dlib_build/libdlib.a(logger_kernel_1.cpp.o): relocation R_X86_64_32 against '.bss' can not be used when making a shared object; recompile with -fPIC- azmath-rdynamicflag, that might export the missing symbol. - Maxim Egorushkin