问题描述
我已经设置了pybind11来构建用c ++编写的python模块。
我在ubuntu系统上安装了python3.6和python3.7,同时安装了python3.6-dev
和python3.7-dev
。然后为我的项目设置cmakelists.txt
文件,如下所示:
set(PYTHONVERSION "3.7")
# None of the lines below works
add_deFinitions(-DPYBIND11_PYTHON_VERSION="${PYTHONVERSION}")
set(PYBIND11_PYTHON_VERSION ${PYTHONVERSION} CACHE STRING "")
set(PYBIND11_PYTHON_VERSION ${PYTHONVERSION})
find_package(Python ${PYTHONVERSION} COMPONENTS Development Interpreter)
set(TARGET proj)
pybind11_add_module(${TARGET} MODULE proj.cpp)
target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if (Python_FOUND)
target_include_directories(${TARGET} PUBLIC ${Python_INCLUDE_Dirs})
endif()
但是,当我构建项目时,它仍然为python3.6
而不是python3.7
生成模块。以下是来自cmake的输出,我发现cmake首先找到python3.6
,甚至没有调用findpython
。
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 9.3.0
[cmake] -- The CXX compiler identification is GNU 9.3.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /usr/bin/gcc-9 - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /usr/bin/g++-9 - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Conan: Adjusting output directories
[cmake] -- Conan: Using cmake global configuration
[cmake] -- Conan: Adjusting default RPATHs Conan policies
[cmake] -- Conan: Adjusting language standard
[cmake] -- Current conanbuildinfo.cmake directory: /home/mpnv38/develop/parcel_dim_pywrapper/build
[cmake] -- Conan: Compiler GCC>=5,checking major version 9
[cmake] -- Conan: Checking correct version: 9
[cmake] -- Found PythonInterp: /usr/bin/python (found version "3.6.9")
[cmake] -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so
[cmake] -- Performing Test HAS_CPP14_FLAG
[cmake] -- Performing Test HAS_CPP14_FLAG - Success
[cmake] -- Found Python: /usr/bin/python3.7 (found suitable version "3.7.5",minimum required is "3.7") found components: Development Interpreter Development.Module Development.Embed
[cmake] -- Configuring done
[cmake] -- Generating done
我想念什么吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)