Recently I found myself in need to use SIP for wrapping some custom C++ Qt library and using it in python. Then I found this repository which looked very promising for my particular project. I have immediately tested code provided in this repo on Manjaro, with Python 3.6 and (Py)Qt 5.9 - no problems. Everything went smooth. But that was only for testing, because I need it to work on Windows 10. And here the problems begun...
My setup:
- Windows 10
- Python 3.6.1
- Qt 5.9.1
- PyQt 5.9.1 (installed from binary)
- SIP 4.19.7
- Microsoft Visual Studio Community 2017
Problems with step one: python configure.py
Since the newest versions of python like to install themselves in C:\Program Files (x86)
almost or all the paths that are added to cmd in configure.py
must be in quotes in order to work. The only exception was config.sip_bin
which for whatever reason did throw error even in quotes, but since I had sip
on my system path I have just omitted the full path and used sip
.
Then of course the known problem with sip: Unable to find file "QtGui/QtGuimod.sip"
. I have managed to solve it with by copying sip directory from PyQt5 source and adding -I "C:\Program Files (x86)\Python36-32\sip"
to sip command.
Finally, since there is no more MSVC 2010 available, we have to use VS2017 Community. Which means that the line qmake_cmd += " -spec win32-msvc2010"
throws an error. Substituting win32-msvc2010
with win32-msvc
, winrt-x86-msvc2015
or winrt-x86-msvc2017
enabled me to move further (it did not throw an error) but I am still not sure whether it is correct and which should I use.
Eventually the python configure.py
did worked and it generated the makefile.
Problems with step two: make
I am not used to compiling stuff on windows, but as it appears windows uses nmake
instead of make
. I do not know how it was with MSVC 2010, but using nmake
with VS 2017 turns out to be a bit tricky. First I had to run cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
to enter the VS 2017 Developer Command Prompt and then I had to source the environment variables with "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
. As stated on Microsoft Forum "it is not a bug, it's a feature" and it is the only way to use nmake
. Eventually the nmake
command worked. But it throws an error:
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
cd src
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe" -f Makefile.Release
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl -BxE:\Qt\5.9.1\mingw53_32\bin\qmake.exe -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E E:\Qt\5.9.1\mingw53_32\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h
E:\Qt\5.9.1\mingw53_32\bin\moc.exe -DUNICODE -DWIN32 -DANALOGCLOCK_LIBRARY -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG --compiler-flavor=msvc --include release/moc_predefs.h -IE:/Qt/5.9.1/mingw53_32/mkspecs/win32-msvc -ID:/Scripts/Qt5toPyQt5-77d3791374723c54195a7dde953bd04775478595/src -IE:/Qt/5.9.1/mingw53_32/include -IE:/Qt/5.9.1/mingw53_32/include/QtWidgets -IE:/Qt/5.9.1/mingw53_32/include/QtGui -IE:/Qt/5.9.1/mingw53_32/include/QtANGLE -IE:/Qt/5.9.1/mingw53_32/include/QtCore -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" analogclock.h -o release\moc_analogclock.cpp
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -DWIN32 -DANALOGCLOCK_LIBRARY -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I. -IE:\Qt\5.9.1\mingw53_32\include -IE:\Qt\5.9.1\mingw53_32\include\QtWidgets -IE:\Qt\5.9.1\mingw53_32\include\QtGui -IE:\Qt\5.9.1\mingw53_32\include\QtANGLE -IE:\Qt\5.9.1\mingw53_32\include\QtCore -Irelease -IE:\Qt\5.9.1\mingw53_32\mkspecs\win32-msvc -Forelease\ @C:\Users\KDZIAD~1\AppData\Local\Temp\nm3EE.tmp
analogclock.cpp
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -DWIN32 -DANALOGCLOCK_LIBRARY -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I. -IE:\Qt\5.9.1\mingw53_32\include -IE:\Qt\5.9.1\mingw53_32\include\QtWidgets -IE:\Qt\5.9.1\mingw53_32\include\QtGui -IE:\Qt\5.9.1\mingw53_32\include\QtANGLE -IE:\Qt\5.9.1\mingw53_32\include\QtCore -Irelease -IE:\Qt\5.9.1\mingw53_32\mkspecs\win32-msvc -Forelease\ @C:\Users\KDZIAD~1\AppData\Local\Temp\nm70C.tmp
moc_analogclock.cpp
lib /NOLOGO /OUT:release\analogclock.lib @C:\Users\KDZIAD~1\AppData\Local\Temp\nm9DC.tmp
cd D:\Scripts\Qt5toPyQt5-77d3791374723c54195a7dde953bd04775478595\modules
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c -nologo -Zm200 -Zc:wchar_t- -FS -Zc:strictStrings -D_HAS_EXCEPTIONS=0 -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -DNDEBUG -DAnalogClock_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -I. -ID:\Scripts\Qt5toPyQt5-77d3791374723c54195a7dde953bd04775478595\src -IE:\Qt\5.9.1\mingw53_32\include -IE:\Qt\5.9.1\mingw53_32\include\QtCore -IE:\Qt\5.9.1\mingw53_32\include\QtGui -IE:\Qt\5.9.1\mingw53_32\include\QtWidgets -I"C:\Program Files (x86)\Python36-32\include" -Fo @C:\Users\KDZIAD~1\AppData\Local\Temp\nmAC4.tmp
sipPyAnalogClockcmodule.cpp
sipPyAnalogClockAnalogClock.cpp
Generating Code...
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:PyAnalogClock.pyd.manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /OUT:PyAnalogClock.pyd @C:\Users\KDZIAD~1\AppData\Local\Temp\nm114D.tmp
LINK : fatal error LNK1181: cannot open input file 'Qt5Core.lib'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x49d'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
And here I am stuck with no idea how to proceed. I suppose that the configure.py
is still not working properly and generates buggy makefiles. I have tried adding some additional paths to sip that will point to where Qt dlls are but with no luck.
I am not experienced with this so I might be missing something obvious. I would be very thankfull if you @eyllanesc could update this example repository for newer versions of Windows, Python, (Py)Qt, SIP and VS or please direct me on the right path on how to proceed. Thank you.