[CMake] embedding lib into a shared object

Ovanes Markarian om_cmake at keywallet.com
Wed Sep 29 06:26:31 EDT 2010


Hello *,

I have some library available as a Linux lib file. Now I need to create a
shared object (actually a MODULE in terms of CMake) out of this lib. The
module is later on loaded using the dlopen-API function.

I created a sample project with

/
+-- testlib
+-- so


testlib - consists of a single cpp file haveing a global variable and a
function returning it.

CMake script:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(testlib CXX)

add_library(testlib STATIC functions.cpp)


so - consists of a cpp file and links against testlib.

CMake script:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(so CXX)

add_library(so MODULE main.cpp)
target_link_libraries(so testlib)
set_target_properties (so PROPERTIES VERSION 1.0 LINKER_LANGUAGE CXX)

and the Root CMakeLists.txt which should build both:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(dll_test CXX)

add_subdirectory(lib)
add_subdirectory(so)
add_dependencies(so lib)


Now my problem is that after the build I can find the symbols from
functions.cpp in the lib file using the nm tool. But these symbols are not
part of the so. How can I force them to be part of the so-Module?


Thanks in advance,
Ovanes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100929/49bf205e/attachment.htm>


More information about the CMake mailing list