mac os x 上的 Cmake,带有完整路径的链接库

发布于 2024-12-01 17:23:39 字数 1688 浏览 1 评论 0原文

我正在尝试使用 cmake 构建 python 扩展。这是 cmake 列表:

cmake_minimum_required(VERSION 2.8)
PROJECT(drtile)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Vigra REQUIRED)
find_package(Boost COMPONENTS python REQUIRED)
find_package(PythonLibs REQUIRED)
find_package(Numpy REQUIRED)

include_directories(
    ${VIGRA_INCLUDE_DIR}
    ${PYTHON_NUMPY_INCLUDE_DIR}
    ${Boost_INCLUDE_DIR}
    ${PYTHON_INCLUDE_DIRS}
    ${PYTHON_INCLUDE_PATH}
)
add_library(drtile SHARED drtile.cpp)
message("xxx ${Boost_PYTHON_LIBRARY} ${VIGRA_NUMPY_CORE_LIBRARY}${VIGRA_NUMPY_IMPEX_LIBRARY}")
target_link_libraries(drtile ${Boost_PYTHON_LIBRARY} ${VIGRA_NUMPY_CORE_LIBRARY}  ${PYTHON_LIBRARY})
IF(WIN32)
   SET_TARGET_PROPERTIES(drtile PROPERTIES OUTPUT_NAME "drtile" PREFIX "" SUFFIX  ".pyd")

ELSE()
    SET_TARGET_PROPERTIES(drtile PROPERTIES OUTPUT_NAME "drtile" PREFIX "" SUFFIX ".so")
ENDIF()

该库已正确编译和链接,但是当我使用 otool 查看喜欢的库时,我得到:

otool -L drtile.so

drtile.so:
/Users/lfiaschi/phd/workspace/lazyflow/lazyflow/drtile/drtile.so (compatibility version 0.0.0, current version 0.0.0)
libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
vigranumpycore.so (compatibility version 0.0.0, current version 0.0.0)
/Users/lfiaschi/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

How can I get CMake to link the drtile.so with the fullpath to vigranumpycore.so and libboost_python.dylib? 谢谢!

I'm trying to build a python extension with cmake. This is the cmake list:

cmake_minimum_required(VERSION 2.8)
PROJECT(drtile)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Vigra REQUIRED)
find_package(Boost COMPONENTS python REQUIRED)
find_package(PythonLibs REQUIRED)
find_package(Numpy REQUIRED)

include_directories(
    ${VIGRA_INCLUDE_DIR}
    ${PYTHON_NUMPY_INCLUDE_DIR}
    ${Boost_INCLUDE_DIR}
    ${PYTHON_INCLUDE_DIRS}
    ${PYTHON_INCLUDE_PATH}
)
add_library(drtile SHARED drtile.cpp)
message("xxx ${Boost_PYTHON_LIBRARY} ${VIGRA_NUMPY_CORE_LIBRARY}${VIGRA_NUMPY_IMPEX_LIBRARY}")
target_link_libraries(drtile ${Boost_PYTHON_LIBRARY} ${VIGRA_NUMPY_CORE_LIBRARY}  ${PYTHON_LIBRARY})
IF(WIN32)
   SET_TARGET_PROPERTIES(drtile PROPERTIES OUTPUT_NAME "drtile" PREFIX "" SUFFIX  ".pyd")

ELSE()
    SET_TARGET_PROPERTIES(drtile PROPERTIES OUTPUT_NAME "drtile" PREFIX "" SUFFIX ".so")
ENDIF()

The library is compiled and linked correctly but when I look at the liked library with otool I get:

otool -L drtile.so

drtile.so:
/Users/lfiaschi/phd/workspace/lazyflow/lazyflow/drtile/drtile.so (compatibility version 0.0.0, current version 0.0.0)
libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
vigranumpycore.so (compatibility version 0.0.0, current version 0.0.0)
/Users/lfiaschi/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

How can I get CMake to link the drtile.so with the fullpath to vigranumpycore.so and libboost_python.dylib?
Thanks!

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

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

发布评论

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

评论(1

戏蝶舞 2024-12-08 17:23:39

您面临 rpath 规则的问题。 添加行来修复它。

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

我认为您可以通过在 PROJECT 命令之前

You are facing problem with rpath rules. I think you can fix it by adding the line

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

before the PROJECT command.

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