开发者

Link my shared library to another (CMAKE)

开发者 https://www.devze.com 2023-01-10 08:44 出处:网络
I\'m currently trying to lin开发者_JAVA技巧k 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

I'm currently trying to lin开发者_JAVA技巧k 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消