0

Trying to deploy a simple PyQt5 application using pyqtdeploy for Windows. I successfully generated the .cpp files along with Makefile via Qt5-vs2015 qmake.

Using Native VS2015 cmd nmake to generate the final .exe file but nmake outputs a fatal error of LNK1181 saying can't open QtGui.lib or sip.lib.

Inside Makefile.Release there are LIBPATH to .lib files which don't exist anywhere on my system. A part of the Makefile.Release:

LIBS =  /LIBPATH:C:\cdev\Python35\Lib\site-packages\PyQt5 QtGui.lib QtCore.lib QtWidgets.lib /LIBPATH:C:\cdev\Python35\libs C:\cdev\Python35\libs\python35.lib /LIBPATH:C:\cdev\Python35\Lib\site-packages sip.lib advapi32.lib shell32.lib user32.lib ws2_32.lib ole32.lib oleaut32.lib C:\cdev\Qt\5.8\msvc2015_64\lib\Qt5Widgets.libC:\cdev\Qt\5.8\msvc2015_64\lib\Qt5Gui.lib C:\cdev\Qt\5.8\msvc2015_64\lib\Qt5Core.lib 

If I exclude these Qt modules inside pyqtdeploy, nmake successfully compiles the application but it won't have gui.

Where are these qt/sip .lib files? I can only find some of them with pyd extension.

Using PyQt 5.8, pyqtdeploy 1.3.2, sip 4.19.2, Qt 5.8, python 3.5.3 on Windows 10

mamady
  • 15
  • 3

1 Answers1

1

Howto: Python3.6 + PyQT5 + pyqtdeploy -> exe:

Installed Visual Studio 2017 Community Edition or whatever is the newest version. Remember to install SDK packages to get the needed headers and such.

After installation, vcvarsall.bat should be found from the following path:

> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat

Installed Qt SDK version 5.8.0

I had to patch qalgorithms.h so it works with VS 2017:

> https://codereview.qt-project.org/#/c/177743/
> Download the .h file and replace it, make a backup just in case from the old version

Added a new ENV variable called INCLUDE so the compiler finds all of the neeeded header files and such:

> C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt;
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include;
> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include;

Now you should have the needed headers and windows libs installed. Next up pyqtdeploy

> pip install pyqtdeploy

From pyqtdeploy documentation:

"pyqtdeploy requires these to be compiled ready for static linking:
    -> sip module (an extension module, written in C.)
    -> pyqt module (an extension module, written in C.)"

This means its time to compile these things from the sources. Get the source packages for these two components and follow the instructions stated here:

https://stackoverflow.com/a/40779370

When finished with compiling and installation, copy all of the necessary .lib files from sip and PyQT directories and put them in a location so the linker finds them.

> sip: <sip-sourcedir>\siplib\sip.pyd & sip.lib
> PyQT5: <component>\release\<component>.lib
> sip libs I copied to python\site-packages\
> PyQT5 libs I copied to python\site-packages\PyQt5

Run vcvarsall.bat and start pyqtdeploy like so:

> "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86

> pyqtdeploy

Configure your settings accordingly -> Build!

Use windeployqt.bat from QT SDK to copy necessary DLL files to your build dir from QT SDK

> C:\Qt\<version>\msvc2015\bin\windeployqt.bat -h

Problem I encountered afterwards:

> "Application failed to start because platform plugin “windows” is missing"
    > The libEGL.dll was missing. Run windeployqt with --compiler-runtime flag

I hope these guidelines might help you on your struggle to deploy your program!