Cannot build Qt SIP project on Windows: gives linkage errors (metacast,metacall,etc)
I have a QWidget, written in C++. I want to create a SIP Python wrapper for it to embed it into another PyQt application.
It is possible, if PyQt is linked against the same version of Qt as embeddable widget is linked.
There is even an example on such embedding: the example and some talks about itу.
And I have even built it under Linux without any problems, just by the manual.
And it even worked!
But for Windows it was not so easy.
I installed Qt 5.8.0. Downloaded SIP sources, built SIP, installed it with make install. Okay, SIP installed.
Then I downlaoded PyQt5 sources, built it (here is a tutorial), copied Qt DLLs into site-packages/PyQt5 -- and PyQt also started working. Okay so far...
But when I tried to build the example from https://github.com/eyllanesc/Qt5toPyQt5 , it failed.
What I did?
I did python3 configure.py -- okay, it passed, Makefiles created.
Code:
D:\Projects\Qt5toPyQt5>C:/Python35/python configure.py
QMake version 3.1
Using Qt version 5.8.0 in D:/Libs/Qt5.8.0/5.8/msvc2015_64/lib
C:\Python35\sip -t WS_WIN -t Qt_5_8_0 *-I D:\Projects\Qt5toPyQt5\sip -I C:\Python35\sip\PyQt5 -I C:\Python35\include -I D:\Projects\Qt5toPyQt5\src -c D:\Projects\Qt5toPyQt5\modules -b D:\Projects\Qt5toPyQt5\modules\PyAnalogClock.sbf -w -o D:\Projects\Qt5toPyQt5\sip\PyAnalogClock.sip
qmake -spec win32-msvc2010
Info: creating stash file D:\Projects\Qt5toPyQt5\src\.qmake.stash
But when I tried to build the Makefile with nmake (Visual Studio 2015 Pro), it crashed:
Code:
D:\Projects\Qt5toPyQt5>nmake
Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
Copyright (C) Microsoft Corporation. *All rights reserved.
* * * *cd src
* * * *"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"
Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
Copyright (C) Microsoft Corporation. *All rights reserved.
* * * *"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe" -f Makefile.Release
Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
Copyright (C) Microsoft Corporation. *All rights reserved.
* * * *cl -BxD:\Libs\Qt5.8.0\5.8\msvc2015_64\bin\qmake.exe -nologo -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -E -Za ..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h
* * * *D:\Libs\Qt5.8.0\5.8\msvc2015_64\bin\moc.exe -DUNICODE -DWIN32 -DWIN64 -DANALOGCLOCK_LIBRARY -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG --compiler-flavor=msvc --include release/moc_predefs.h -ID:/Libs/Qt5.8.0/5.8/msvc2015_64/mkspecs/win32-msvc2010 -ID:/Projects/Qt5toPyQt5/src -ID:/Libs/Qt5.8.0/5.8/msvc2015_64/include -ID:/Libs/Qt5.8.0/5.8/msvc2015_64/include/QtWidgets -ID:/Libs/Qt5.8.0/5.8/msvc2015_64/include/QtGui -ID:/Libs/Qt5.8.0/5.8/msvc2015_64/include/QtANGLE -ID:/Libs/Qt5.8.0/5.8/msvc2015_64/include/QtCore -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.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.10240.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.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.10240.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" analogclock.h -o release\moc_analogclock.cpp
* * * *cl -c -nologo -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -EHsc -DUNICODE -DWIN32 -DWIN64 -DANALOGCLOCK_LIBRARY -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I. -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtWidgets -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtGui -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtANGLE -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtCore -Irelease -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\mkspecs\win32-msvc2010 -Forelease\ @C:\Users\felix\AppData\Local\Temp\nm6846.tmp
analogclock.cpp
* * * *cl -c -nologo -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -EHsc -DUNICODE -DWIN32 -DWIN64 -DANALOGCLOCK_LIBRARY -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I. -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtWidgets -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtGui -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtANGLE -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtCore -Irelease -I..\..\..\Libs\Qt5.8.0\5.8\msvc2015_64\mkspecs\win32-msvc2010 -Forelease\ @C:\Users\felix\AppData\Local\Temp\nm6C2D.tmp
moc_analogclock.cpp
* * * *lib /NOLOGO */OUT:release\analogclock.lib @C:\Users\felix\AppData\Local\Temp\nm6FE6.tmp
* * * *cd D:\Projects\Qt5toPyQt5\modules
* * * *"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"
Microsoft (R) Program Maintenance Utility Version 14.00.23506.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:\Projects\Qt5toPyQt5\src -ID:\Libs\Qt5.8.0\5.8\msvc2015_64\include -ID:\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtCore -ID:\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtGui -ID:\Libs\Qt5.8.0\5.8\msvc2015_64\include\QtWidgets -IC:\Python35\include -Fo @C:\Users\felix\AppData\Local\Temp\nm7032.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\felix\AppData\Local\Temp\nm7957.tmp
* Creating library PyAnalogClock.lib and object PyAnalogClock.exp
sipPyAnalogClockAnalogClock.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual struct QMetaObject const * __cdecl AnalogClock::metaObject(void)const " (__imp_?metaObject@AnalogClock@@UEBAPEBUQMetaObject@@XZ) referenced in function "public: virtual struct QMetaObject const * __cdecl sipAnalogClock::metaObject(void)const " (?metaObject@sipAnalogClock@@UEBAPEBUQMetaObject@@XZ)
sipPyAnalogClockAnalogClock.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void * __cdecl AnalogClock::qt_metacast(char const *)" (__imp_?qt_metacast@AnalogClock@@UEAAPEAXPEBD@Z) referenced in function "public: virtual void * __cdecl sipAnalogClock::qt_metacast(char const *)" (?qt_metacast@sipAnalogClock@@UEAAPEAXPEBD@Z)
sipPyAnalogClockAnalogClock.
obj : error LNK2019
: unresolved external symbol
"__declspec(dllimport) public: virtual int __cdecl AnalogClock::qt_metacall(enum QMetaObject::Call,int,void * *)" (__imp_?qt_metacall@AnalogClock@@UEAAHW4Call@
QMetaObject@@HPEAPEAX@Z
) referenced in function
"public: virtual int __cdecl sipAnalogClock::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@sipAnalogClock@@UEAAHW4Call@
QMetaObject@@HPEAPEAX@Z
)sipPyAnalogClockAnalogClock.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl AnalogClock::AnalogClock(class QWidget *)" (__imp_??0AnalogClock@@QEAA@PEAVQWidget@@@Z) referenced in function init_type_AnalogClock
sipPyAnalogClockAnalogClock.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: virtual void __cdecl AnalogClock::paintEvent(class QPaintEvent *)" (__imp_?paintEvent@AnalogClock@@MEAAXPEAVQPaintEvent@@@Z) referenced in function meth_AnalogClock_paintEvent
sipPyAnalogClockAnalogClock.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const AnalogClock::staticMetaObject" (__imp_?staticMetaObject@AnalogClock@@2UQMetaObject@@B) referenced in function "void __cdecl `dynamic initializer for 'plugin_AnalogClock''(void)" (??__Eplugin_AnalogClock@@YAXXZ)
PyAnalogClock.pyd : fatal error LNK1120: 6 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
Can I somehow cope with it?