C++ CMake,OS X错误的Python版本
我试图使用/学习CMake将Python嵌入到C++应用程序中,使用Qt. 我使用FIND_包试图在中安装Anaconda Python 2.7.9的非系统包。我无法让编译器看到系统安装版本2.7.5以外的任何版本 我的CMakeLists.txt是:C++ CMake,OS X错误的Python版本,c++,qt,python-2.7,cmake,C++,Qt,Python 2.7,Cmake,我试图使用/学习CMake将Python嵌入到C++应用程序中,使用Qt. 我使用FIND_包试图在中安装Anaconda Python 2.7.9的非系统包。我无法让编译器看到系统安装版本2.7.5以外的任何版本 我的CMakeLists.txt是: #Minimum CMAKE version CMAKE_MINIMUM_REQUIRED(VERSION 3.0) #Name the project PROJECT(embedpython) #Set the version number
#Minimum CMAKE version
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
#Name the project
PROJECT(embedpython)
#Set the version number
SET(embedpython_VERSION_MAJOR 0)
SET(embedpython_VERSION_MINOR 1)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
FIND_PACKAGE(Qt4 4.8.6 REQUIRED QtGui QtCore)
QT4_WRAP_CPP(embedpython_HEADERS_MOC ${embedpython_HEADERS})
message(status "QT FOUND: ${Qt4_FOUND}")
FIND_PACKAGE(PythonLibs 2.7.9 REQUIRED)
message(status "libs found: ${PYTHONLIBS_FOUND}")
MESSAGE(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
MESSAGE(STATUS "PYTHON_INCLUDE_PATH: ${PYTHON_INCLUDE_PATH}")
MESSAGE(STATUS "PYTHONLIBS_VERSION: ${PYTHONLIBS_VERSION_STRING}")
MESSAGE(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
SET(embedpython_SOURCES
main.cpp
mainwindow.cpp
pythonutilsimpl.cpp
ipcepythonrunner.cpp)
SET(embedpython_HEADERS
mainwindow.h
pythonutilsimpl.h
ipcepythonutils.h
ipcepythonrunner.h)
ADD_EXECUTABLE(embedpython ${embedpython_SOURCES} ${embedpython_HEADERS_MOC})
TARGET_LINK_LIBRARIES(embedpython ${QT_LIBRARIES} ${PYTHON_LIBRARIES})
哪些产出:
cmpt:build user$ /Applications/CMake.app/Contents/bin/cmake .. && make
statusQT FOUND: TRUE
statuslibs found: TRUE
-- PYTHON_LIBRARIES: /home/me/anaconda/lib/libpython2.7.dylib
-- PYTHON_INCLUDE_PATH: /home/me/anaconda/include/python2.7
-- PYTHONLIBS_VERSION: 2.7.9
-- PYTHON_INCLUDE_DIRS: /home/me/anaconda/include/python2.7
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/Desktop/EmbedPython/build
Scanning dependencies of target embedpython_automoc
[ 16%] Automatic moc for target embedpython
Generating moc_mainwindow.cpp
[ 16%] Built target embedpython_automoc
Scanning dependencies of target embedpython
[ 33%] Building CXX object CMakeFiles/embedpython.dir/main.cpp.o
[ 50%] Building CXX object CMakeFiles/embedpython.dir/mainwindow.cpp.o
[ 66%] Building CXX object CMakeFiles/embedpython.dir/pythonutilsimpl.cpp.o
[ 83%] Building CXX object CMakeFiles/embedpython.dir/ipcepythonrunner.cpp.o
[100%] Building CXX object CMakeFiles/embedpython.dir/embedpython_automoc.cpp.o
Linking CXX executable embedpython
[100%] Built target embed python
使用ccmake,我设置了PYTHON_INCLUDE_DIR和PYTHON_库,以便FIND_包能够成功地找到python2.7.9
在C++中,我调试了Python版本和路径。毫无疑问,这将返回Python 2.7.5。在CMake文件中需要什么才能使Python版本达到我的目标路径