I am trying to create a dynamic library written using pure "C" (libSetupConfig.so) and another one using "C++" (libUserAnalysis.so) such that the second one uses the functionality of the first one. The project is built using CMake.
The full source is here: https://github.com/evovch/Useful/tree/master/go4_5H_processor
Compilation runs fine. Output is here: https://github.com/evovch/Useful/blob/master/go4_5H_processor/compile.txt
When trying to use the library, I get a runtime error like that: go4analysis: symbol lookup error: .../build/src/libUserAnalysis.so: undefined symbol: _Z18InitStcSetupConfigP17_stc_setup_config
https://github.com/evovch/Useful/blob/master/go4_5H_processor/err.txt
So, I check that the symbol is present in the so:
nm libSetupConfig.so
...
0000000000001140 T InitStcSetupConfig
...
https://github.com/evovch/Useful/blob/master/go4_5H_processor/auxiliary/nm_output.txt
To be honest, I don't know how to interpret the full symbol string _Z18InitStcSetupConfigP17_stc_setup_config
My top CMakeLists.txt contains the following lines:
add_subdirectory(src)
add_subdirectory(setupconfig)
The CMakeLists.txt under src, which corresponds to the libUserAnalysis.so contains:
add_library(UserAnalysis SHARED ${SOURCE_LIB})
target_link_libraries(UserAnalysis Go4Analysis)
target_link_libraries(UserAnalysis SetupConfig)
The CMakeLists.txt under setupconfig which corresponds to libSetupConfig.so contains:
add_library(SetupConfig SHARED ${SOURCE_LIB})
add_executable(setup_config_test ${SOURCE_EXE})
target_link_libraries(setup_config_test SetupConfig)
From this I assume that the libUserAnalysis.so will be linked against libSetupConfig.so
I also check that the libSetupConfig.so library is linked when compiling the libUserAnalysis.so; see the last lines of https://github.com/evovch/Useful/blob/master/go4_5H_processor/compile.txt the necessary flags -L and -l are there -L/home/evovch/soft/go4-5.3.0_fairsoftroot/lib -Wl,-rpath,/home/evovch/soft/FairSoft_install/lib/root:/home/evovch/soft/go4-5.3.0_fairsoftroot/lib:/home/evovch/Documents/Useful/go4_5H_processor/build/setupconfig -lGo4Analysis ../setupconfig/libSetupConfig.so
PS. I understand that the problem most probably comes not from the fact that the languages are different.