将我的共享库链接到另一个(CMAKE)

发布于 2024-09-13 09:33:50 字数 112 浏览 0 评论 0原文

我目前正在尝试将我编写的 CXX 库链接到 VTK(一个 CMake 制作的库),最终创建一个具有我的代码功能并可以解析 VTK 中的符号的共享库。我需要共享最终结果,因为我需要在运行时用 Java 调用该库。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双手揣兜 2024-09-20 09:33:50

听起来您需要使用 target_link_libraries,因此最小的 CMake 块可能看起来像这样,

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

这将添加一个名为 mylib(Linux 上的 libmylib.so)的共享库,该库链接到 vtkRendering(此处可以添加多个库)。查看“cmake --help-commands”以获取 CMake 命令的完整列表。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文