库未加载:@ rpath / libboost_thread.dylib

时间:2018-10-04 03:13:54

标签: python boost linker boost-python rpath

我在boost Jamroot的帮助下构建了一个基于boost python的.so文件,以便在Python中使用.so。当我用Python导入库时,出现以下错误:

import vision_library
ImportError: dlopen(/../Vision/pyVision/python_scripts/vision_library.so, 2): Library not loaded: @rpath/libboost_thread.dylib
  Referenced from: /../Vision/pyVision/python_scripts/vision_library.so
  Reason: image not found

这是Jamroot:

# Copyright David Abrahams 2006. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

import option ;
import feature ;
import python ;

if ! [ python.configured ]
{
    ECHO "notice: no Python configured in user-config.jam" ;
    ECHO "notice: will use default configuration" ;
    using python : 2.7 ;
}

# Platform architecture provided as an environment variable
import os ; 
local ARCH = [ os.environ ARCH ] ;

# Specify the path to the Boost project.  If you move this project,
# adjust this path to refer to the Boost root directory.
use-project boost
  : ../../thirdparty/boost/boost_1_62_0 ;

alias boost_dependencies
  : /boost/python//boost_python
    /boost/thread//boost_thread
  ;

lib opencv_core : : <name>libopencv_core <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_features2d : : <name>libopencv_features2d <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_video : : <name>libopencv_video <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_videoio : : <name>libopencv_videoio <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_videostab : : <name>libopencv_videostab <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_ml : : <name>libopencv_ml <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_imgproc : : <name>libopencv_imgproc <search>../../thirdparty/opencv/build/lib/ ;
lib opencv_objdetect : : <name>libopencv_objdetect <search>../../thirdparty/opencv/build/lib/ ;

# Set up the project-wide requirements that everything uses the
# boost_python library from the project whose global ID is
# /boost/python.
project
  : requirements <library>boost_dependencies
                 <include>../
                 <include>../../
                 <include>../../Common/include
                 <include>../../PythonShared/include
                 <include>../../Vision/include
                 <include>../../thirdparty/opencv/build/include
                 <include>/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include
  : requirements <library>../../Common/build/$(ARCH)/lib/libCommon.a
                 <library>../../Vision/build/$(ARCH)/lib/libVision.a
                 <library-path>../../thirdparty/opencv/build/lib/
                 <linkflags>-lm 
                 <linkflags>-lpthread
                 <linkflags>-lopencv_core
                 <linkflags>-lopencv_features2d
                 <linkflags>-lopencv_video
                 <linkflags>-lopencv_videoio
                 <linkflags>-lopencv_videostab
                 <linkflags>-lopencv_ml
                 <linkflags>-lopencv_imgproc
                 <linkflags>-lopencv_objdetect
  ;

# Declare the three extension modules.  You can specify multiple
# source files after the colon separated by spaces.
python-extension vision_library : src/pyboost_cv3_converter.cpp
                                  src/PythonBindings.cpp
                                  src/PythonDocumentScanner.cpp
                                  src/PythonFaceDetector.cpp
                                  src/PythonModule.cpp
                                  src/PythonMotionDetector.cpp                                  
                                  src/PythonMotionDetectorConfiguration.cpp
                                  src/PythonMotionDetectorResult.cpp
                                  src/PythonOfflineVideoStabilizer.cpp
                                  src/PythonStreamingVideoStabilizer.cpp
                                  src/PythonTimeLapser.cpp
                                  src/Trace.cpp ;

install boost_libraries
  : boost_dependencies
  ;

# A little "rule" (function) to clean up the syntax of declaring tests
# of these extension modules.
local rule run-test ( test-name : sources + )
{
    import testing ;
    testing.make-test run-pyd : $(sources) : : $(test-name) ;
}

# Declare test targets
# run-test hello : vision_library test.py ;

如何解决rpath问题?

1 个答案:

答案 0 :(得分:0)

不确定是否有帮助,但是我通过删除以下内容解决了该问题:

/boost/thread//boost_thread