Compiling PythonQt against Python 3.6 and Qt 5.10 on Windows VS 2017
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Hi,
I'm trying to build PythonQt to try it out. I'm rather green when it comes to compiling C/C++packages but am fairly familiar with Python. The way compiling any C based opensource projects usually goes for me is spend the weekend sorting out dependencies, try Visual Studio, get a C1083, google it alot, try mingw, Get LNK1122 erros, google it alot, give up/get the binary. I would like to tackle this build properly and weed out the common errors I encounter in the hopes it will help some one else. To this end I will be quite explicit in what I have/haven't done.
1 ) I had to uninstall visual studio 2015 so followed their advice https://msdn.microsoft.com/en-us/library/mt720585.aspx
2) Installed visual studio 2017 as that is the defacto for Python 3.6, included the Python option and the C compiler options (Sorry I didn't take a screen shot but it amounts to the first three blocks in the community installer and anything that said Python)
3) Installed Qt via their installer, included QtCreator and the MVSC 2017 64 bit and MSVC 2015 32 bit kits.
4) Download Python to a sensible spot (E:\src\Python)
- build python using their build script (Allowed all external libraries to be built)
5) Download PythonQt3..2 to a sensible spot (E:\src\PythonQt)
- Buitld PythonQt, specifying PYTHON_PATH as E:\src\python\ and PYTHON_LIBS as E:\src\Python\PCBuild\win32, ran vsDevCmd (vcvarsall32 does appear to have been superceded by vsdevcmd)
Subsequently I encountered my first error :
This seems to be a mismatch between the Qt build kit binaries i.e. the MSVC 2017 64 bit kit and the Python build i.e. PCBuild\win32. I would be gateful to anyone who has encountered this error and can suggest a workaround/fix ?
In the interim I'm now trying a build of Qt using MSVC 2017 targeting a 32 bit build and am installing the MSVC 2015 32 bit kit as an alternative. This begs the question of how do I specify which Qt build kit to use.
Hi Carel,
Are you passing the correct architecture to "vsdevcmd.bat". As far as I can see Qt doesn't provide 32 bit builds yet for MSVC 2017. All the QT DLLs are 64 bit so you need to launch the MSVC like this to ensure it picks up the 64 bit toolset instead of the 32 bit toolset:
vsdevcmd.bat -arch=amd64
You'll need a 64 bit version of Python too. There is probably a way to link against a 32b python installation but I don't know how to do it. I don't usually bother compiling Python to get debug builds. I usually just modify the python/include/pyconfig.h file and comment out this line: