sparkFinder
sparkFinder

Reputation: 3404

Link my shared library to another (CMAKE)

I'm currently trying to link a CXX library that I've written to a VTK, a CMake made library - to end up creating a shared library that has my code's functionality and can resolve the symbols from VTK. I need the end result to be shared because I'd need to call the library up at runtime in Java.

Upvotes: 1

Views: 3742

Answers (1)

Marcus D. Hanwell
Marcus D. Hanwell

Reputation: 6855

It sounds like you need to use target_link_libraries, so a minimal CMake block might look like,

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_library(mylib SHARED sourcefile.cxx sourcefile2.cxx)
target_link_libraries(mylib vtkRendering)

This would add a shared library called mylib (libmylib.so on Linux), that links to vtkRendering (multiple libraries could be added here). Check out 'cmake --help-commands' for a full list of CMake commands.

Upvotes: 5

Related Questions