Compile PythonQt 3.1 on macOS Sierra fails
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
I tried to compile PythonQt 3.1 on macOS Sierra (XCode 8.2) but got the following error message:
In file included from PythonQtClassInfo.cpp:42:
In file included from ./PythonQtClassInfo.h:41:
In file included from ./PythonQt.h:59:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/locale:468:15: error:
C++ requires a type specifier for all declarations
char_type toupper(char_type c) const
^
/System/Library/Frameworks/Python.framework/Headers/pyport.h:731:29: note: expanded from macro 'toupper'
define toupper(c) towupper(btowc(c))
followed by many more. It seems that there is some conflct with macro definitions (e.g. "toupper") in the new macOS Python framework.
Any help would be highly appreciated!
Some digging revealed that this is apparently an old issue with a fix that went in to pyport.h for issues with isspace/toupper/et al. on FreeBSD's libc and Mac OS X. The good news is that it can easily be fixed by including <python.h> into the following PythonQt files (I added them as the first include):
With these little changes PythonQt 3.1 compiles and works fine on macOS 10.12 Sierra (tested with Qt 5.7.1).
Regards,
Rainer
Ok, I will add that to the svn trunk. Thanks for posting your findings.