2

I have a C++ project using Qt5 (also compiles with Qt4) which I want to make available in python (preferable 3.4). In order to do this I use PyQt4 (because of the QtXml module which is, as far as I know, not available in PyQt5 anymore) and sip. This all works perfectly on my linux machine. But unfortunately I need it for windows and can't get it run. What I have done so far:

  • A very small example without Qt or other dependencies (one function which returns an integer) works. Even with gcc. But after an "bad reloc" error in my project I switched to the MSVC
  • My python 3.4 was build with "MSC v.1600 32 bit (Intel)" "on win32" so according to What version of Visual Studio is Python on my computer compiled with? I downloaded Qt 5.2.1 MSVC2010 and Microsoft Visual Studio Express 2010 SP1
  • I assume that the precompiled PyQt4-4.11.2-gpl-Py3.4-Qt5.3.1-x32 should fit
  • In order to get the sip.h and sipconfig.py file I compiled sip (4.16.3).

From now on I am unsure what to do. I have to admit that I have no knowledge about libraries.

  • The C++/Qt project is compiled with QtCreator with CONFIG += staticlib and TEMPLATE = lib. The resulting *.lib (here: xml2db.lib) is been copied to the folder where my sip files are (e.g. sipxml2dbcmodule.cpp)

So via the "VS Command Prompt" nmake throws fatal (link) errors. I'm unsure what the needed compiler flags should be or if the staticlib is wrong. My flags are:

LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:$(TARGET).manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NODEFAULTLIB:library /LIBPATH:/LIBPATH:C:\Qt\5.2.1\msvc2010\lib
LIBS = /LIBPATH:C:\Python34\libs python34.lib xml2db.lib /LIBPATH:C:\Qt\5.2.1\msvc2010\lib\Qt5Xmld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Sqld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Cored.lib
$(TARGET): $(OFILES)
$(LINK) $(LFLAGS) /OUT:$(TARGET) $(OFILES) $(LIBS)

Where target is "myTools.pyd". It results in

sipmyToolscmodule.cpp
sipmyToolsxml2db.cpp
Generating Code...
        link /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:myTools
.pyd.manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NODEFAULTLIB:library /LIBPATH:
C:\Qt\5.2.1\msvc2010\lib /OUT:myTools.pyd sipmyToolscmodule.obj sipmyToolsxml2db
.obj /LIBPATH:C:\Python34\libs python34.lib xml2db.lib /LIBPATH:C:\Qt\5.2.1\msvc
2010\lib\Qt5Xmld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Sqld.lib C:\Qt\5.2.1\msvc2010\l
ib\Qt5Cored.lib
xml2db.lib(xml2db.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_L
EVEL': value '2' doesn't match value '0' in sipmyToolscmodule.obj
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_i
nfo(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIB
CMT.lib(typinfo.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall
 type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z)
already defined in LIBCMT.lib(typinfo.obj)
   Creating library myTools.lib and object myTools.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
se /NODEFAULTLIB:library
myTools.pyd : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\link.EXE"' : return code '0x491'
Stop.

I would be pleased for an answer or fresh idea. Thanks in advance.

EDIT I don't know exactly how I solved it but here are a few more hints that helped me to solve it.

  • Since sip 5 won't have the build system I tried to create a qmake project. To do so I downloaded the pyqt source package and looked at the project files and adjusted it to my needs.
  • Especially when you are changing the qmake project file it might be usefull to delete the make, object and/or moc files.
  • The qt version should perfectly match to the pyqt version (actually I don't mean the version itself but the qt version it was compiled for)

Good luck for those who have similiar problems

Community
  • 1
  • 1
Daniel
  • 141
  • 1
  • 10
  • use slash not backslash as directory separator! Qt will handle this properly on windows! back slash has special meaning in *.pro file! – Marek R Oct 07 '14 at 15:08
  • thanks, but in my *.pro file I have not specified a directory. The backslash is an end of line symbol or so? – Daniel Oct 08 '14 at 08:16

0 Answers0