Skip to content

compile against python 2.7 (on osx) #13

Open
@iltommi

Description

@iltommi

Hi,
I'm trying to use cmake to compile python qt on osx wth qt with qt installed via homebrew:

/usr/local/opt/qt5/bin/qmake --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/local/Cellar/qt5/5.5.1_2/lib

I cmaked with

10:56 ~/PythonQt/my_build > cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-5 -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/ ..
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/local/bin/gcc-5
-- Check for working C compiler: /usr/local/bin/gcc-5 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/bin/g++-5
-- Check for working CXX compiler: /usr/local/bin/g++-5 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.6") 
-- Qt5WidgetsConfig.cmake
-- Qt5WidgetsConfig.cmake
-- Qt5WidgetsConfig.cmake
-- Qt5WidgetsConfig.cmake
-- Building Qt5Python27 + Qt5Python27_QtAll (shared Qt 5.5.1 + Python 2.7.10 | Release | Static)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tommaso/PythonQt/my_build

but get this error

[  9%] Building CXX object src/CMakeFiles/Qt5Python27.dir/PythonQtImporter.cpp.o
cd /Users/tommaso/PythonQt/my_build/src && /usr/local/bin/g++-5   -DPYTHONQT_STATIC -DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I/usr/include/python2.7 -I/Users/tommaso/PythonQt/src -iframework /usr/local/opt/qt5/lib -I/usr/local/opt/qt5/lib/QtCore.framework/Headers -I/usr/local/opt/qt5/./mkspecs/macx-clang -I/usr/local/opt/qt5/lib/QtGui.framework/Headers -I/System/Library/Frameworks/OpenGL.framework/Headers -I/usr/local/opt/qt5/lib/QtWidgets.framework/Headers  -O3 -DNDEBUG   -fPIC -o CMakeFiles/Qt5Python27.dir/PythonQtImporter.cpp.o -c /Users/tommaso/PythonQt/src/PythonQtImporter.cpp
/Users/tommaso/PythonQt/src/PythonQtImporter.cpp: In function 'PyObject* PythonQtImporter_get_data(PyObject*, PyObject*)':
/Users/tommaso/PythonQt/src/PythonQtImporter.cpp:356:18: error: 'PyExc_FileNotFoundError' was not declared in this scope
     PyErr_Format(PyExc_FileNotFoundError, "Resource not found: %s", path);
                  ^
make[2]: *** [src/CMakeFiles/Qt5Python27.dir/PythonQtImporter.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/Qt5Python27.dir/all] Error 2
make: *** [all] Error 2

Which looks like a missing reference to python3 error.

What did I miss? So, my questions are:

  1. How to tell to compile for python2.7
  2. Is there a way to tell cmake to use the python framework located in python-config --prefix /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7

Thanks

p.s. I have to change the default compiler to g++5 otherwise I get these errors HERE

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions