BG
We have a product in the late stages of development, the architecture of which implements hardware/functionality support as plugins loaded at startup (impl via Boost::DLL). Hardware support vendor drivers are typically statically linked to the plugin DSO to travel as a single drop-in, well, plugin. It works well.
The problem case is a card purchased for which there is no option for a static vendor lib – it’s between 1 and 3 DSOs depending on the API calls used. Our developer has implemented an abstraction class (call it fooClass) as a subclass of a base in one of the vendor DSOs. fooClass is packaged as a static library to be consumed by our plugin DSO. Copies of the libs exist in a source tree subdir to satisfy build-time link on development systems but the runtime libs are in a vendor directory added to ld.so.conf on the production devices.
Problem
The subclass static lib fooClass must access vendor DSO methods (seems to) yet so too must the plugin DSO – it uses an instance of fooClass via static fooClassLib but also makes direct calls to vendor DSO base class methods, which segfault (nm shows as Unresolved)**.
How do I link to ensure vendor DSO symbols are passed through correctly to plugin DSO?
fooClassLib
set( LIBRARIES
ziodaq
ziodaqutil
)
add_library(${TARGET_NAME} STATIC ${SOURCES} ${HEADERS})
set_property(TARGET ${TARGET_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON) # usable by plugin DSO
target_link_options(${TARGET_NAME} PRIVATE LINKER:-L${CMAKE_CURRENT_SOURCE_DIR}/ztech/lib)
target_link_libraries(${TARGET_NAME} PUBLIC ${LIBRARIES})
The plugin DSO that consumes is built separately and linked as follows:
set( LIBRARIES
<snip>
dl
fooClassLib # a static lib we built elsewhere
ziodaq # hardware vendor dso
ziodaqutil # hardware vendor dso
)
# -- our plugin target
add_library(${TARGET_NAME} SHARED ${HEADERS} ${SOURCES})
set_target_properties( ${TARGET_NAME} PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION} )
target_link_options(${TARGET_NAME} PRIVATE LINKER:-L${PROJECT_BINARY_DIR}/copy/of/vendor/libs)
target_include_directories(${TARGET_NAME} PRIVATE ${VENDOR_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} PRIVATE ${LIBRARIES})
add_dependencies(${TARGET_NAME} SHMEM_HDRS fooClassLib)