找不到符号:预期用于:平面名称空间Mac OSX上CMAKE + Jamroot错误

时间:2020-05-20 05:43:18

标签: c++ boost cmake

我有一个使用CMAKE创建的静态库,如下所示:

cmake_minimum_required(VERSION 3.4.1)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../tools/cmake/CMakeLists.txt)

set(CMAKE_CXX_STANDARD 11)

if (NOT ANDROID)
    include_directories(${SHARED_THIRD_PARTY_DIR}/opencv/build/${BUILD_ARCHITECTURE}/include/)
endif (NOT ANDROID)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../Common/include)

add_library(
    Vision

    STATIC

    libVision/Blob.cpp
    libVision/BlobDetector.cpp
    libVision/Configuration.cpp
    libVision/DetectionBasedBlobTracker.cpp
    libVision/DocumentScanner.cpp
    libVision/FaceDetector.cpp
    libVision/MixtureOfGaussianBackgroundSubtraction.cpp
    libVision/Module.cpp
    libVision/MotionDetector.cpp
    libVision/MotionDetectorConfiguration.cpp
    libVision/MotionEstimatorL1Builder.cpp
    libVision/MotionEstimatorRansacL2Builder.cpp
    libVision/OfflineVideoStabilizer.cpp
    libVision/StreamingVideoStabilizer.cpp
    libVision/TimeLapser.cpp
    libVision/Tracker.cpp
    libVision/VideoStabilizerConfiguration.cpp
)

if (NOT ANDROID)
    enable_testing()
    #add_subdirectory(utVision)
endif (NOT ANDROID)

我正在使用Jamroot与静态库链接以创建.so文件:

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/system//boost_system
  ;
lib opencv_core : : <name>libopencv_core <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_calib3d : : <name>libopencv_calib3d <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_features2d : : <name>libopencv_features2d <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_highgui : : <name>libopencv_highgui <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_imgcodecs : : <name>libopencv_imgcodecs <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_imgproc : : <name>libopencv_imgproc <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_ml : : <name>libopencv_ml <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_objdetect : : <name>libopencv_objdetect <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_photo : : <name>libopencv_photo <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_video : : <name>libopencv_video <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_videoio : : <name>libopencv_videoio <search>../../thirdparty/opencv/build/native/lib/ ;
lib opencv_videostab : : <name>libopencv_videostab <search>../../thirdparty/opencv/build/native/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/native/include
                 <include>/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include
  : requirements <library>../../Common/build/$(ARCH)/libCommon.a
                 <library>../../Vision/build/$(ARCH)/libVision.a
                 <library-path>../../thirdparty/opencv/build/native/lib/
                 <linkflags>-lm
                 <linkflags>-lpthread
                 <linkflags>-lopencv_core
                 <linkflags>-lopencv_calib3d
                 <linkflags>-lopencv_features2d
                 <linkflags>-lopencv_highgui
                 <linkflags>-lopencv_imgproc
                 <linkflags>-lopencv_imgcodecs
                 <linkflags>-lopencv_objdetect
                 <linkflags>-lopencv_photo
                 <linkflags>-lopencv_ml
                 <linkflags>-lopencv_video
                 <linkflags>-lopencv_videoio
                 <linkflags>-lopencv_videostab
  ;

# 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 ;

# Put the extension and Boost.Python DLL in the current directory, so
# that running script by hand works.
install convenient_copy
  : vision_library
  : <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
    <location>build
  ;

我加载了vision_library.so:

ImportError: dlopen(/../shared/Vision/pyVision/build/vision_library.so, 2): Symbol not found: __ZTVN6shared6vision12FaceDetectorE
  Referenced from: /../shared/Vision/pyVision/build/vision_library.so
  Expected in: flat namespace
 in /../shared/Vision/pyVision/build/vision_library.so

当我这样做时,在.a文件中找到了符号__ZTVN6shared6vision12FaceDetectorE:

nm build/native/libVision.a | grep __ZTVN6shared6vision12FaceDetectorE
0000000000003d78 S __ZTVN6shared6vision12FaceDetectorE

但是当我为nm做纳米操作时,我得到了:

nm /../shared/Vision/pyVision/build/vision_library.so | grep __ZTVN6shared6vision12FaceDetectorE
                 U __ZTVN6shared6vision12FaceDetectorE

不确定与.so链接后为何未定义。

0 个答案:

没有答案