尝试将自定义c ++模块导入python时出现以下错误。
未定义的符号:_ZNK5boost6python7objects21py_function_impl_base9max_arityEv
我看到有几个人在CMake文件中通过添加以下行来解决这个问题
target_link_libraries(
zoo ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}
)
虽然这对我来说似乎不起作用。这是整个cmake文件。
cmake_minimum_required(VERSION 3.3)
project(zoo)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
# Trying to get the python files.
find_package(PythonLibs REQUIRED)
find_package(Boost 1.54.0 COMPONENTS program_options REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
include_directories(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} "/usr/include/python2.7")
link_directories(${Boost_LIBRARY_DIR})
add_library(zoo SHARED ${SOURCE_FILES})
target_link_libraries(zoo ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
任何想法?