Compiling with PythonQt_QtAll::init(); in Visual Studio 2010 (64 bit)
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Greetings,
My question has two folds:
1 - PythonQt_QtAll::init(); is needed for what exactly?
2 - Using source from patch #3, I use CMake to generate the VS x64 solution. I checked:
PythonQt_DEBUG
PythonQt_Wrap_QtAll
PythonQt_Wrap_Qtcore
PythonQt_Wrap_Qtgui
PyhtonQt.lib compiles without problems but when I use the library in my project, PythonQt_QtAll::init(); is undefined.
If I add PythonQt_QtAll.h, I get PythonQt_QtAll::init(); unresolved...
What am I missing?
Note: Can't compile PythonQt.lib in debug mode because of unresolved issue with std::vector.
Thx
Last edit: Neosettler 2013-05-25
Configuring QtAll in means that you get ALL wrapped Qt libraries (Qtnetwork, QtWebKit, ...), I think you don't need Qtcore and Qtgui individually if you use that.
If you don't need them all, try building without QtAll first.
I'm not using the CMake files, they are a contribution by the Slicer folks and
I had no time to test them. Maybe the QtAll CMake option is broken?
I've been pulling my hair out over this and I think QtAll is broken, yes. The CMake for windows (visual studio x64) needs some love. It is quite cumbersome as Pyhton, and Qt needs to be compiled with VS x64. I succeeded but it is not straight out of the box.
If someone is on to this, I'd be very interested in the following fix!
As I said, the CMakeFiles are contributed and not fully documented. I had a quick glance and I think it works like this:
include "PythonQt_QtBindings.h"
...
PythonQt::init()
PythonQt_init_QtBindings();
The call to PythonQt_init_QtBindings() will initialize the wrappers that you told CMake to build into PythonQt.
This is different to the qmake approach that is used in the PythonQt examples, those will only work out-of-the-box when qmake is used to build them.
This could really need some cleanup, but I can't promise anything right now.
Last edit: Florian Link 2013-05-26
hey Florian, thank you for your feedback,
PythonQt_init_QtBindings() is not doing anything as the #defines are not present in the solution. Plus, being forced to build Python is quite en endeavor and means that we need to distribute our own python modules. It's been quite a nightmare so far trying to make a workable PythonQt and I'm still not certain if the efforts will pay off. Not to mentioned that the debug version doesn't compile either.
It saddens me but it looks like I'll be force to abandoned PythonQt unless some efforts is put in for Visual studio developers!
As I explained to you, the CMake files are a contribution, the official way to build PythonQt is to use qmake and that works on all platforms.
Regarding CMake, I think you should be able to get it working,
those defines are automatically set via CMake when configuring, so I guess
something in your configure step went wrong or the CMake script is broken.
But anyway, PythonQt is free software, nobody forces you to use it.
Hi Florian, correct me if I'm wrong but if my project uses VS, binaries that qmake generates wont be compatible with my project right?
I understand the CMake files are a contribution and I'm simply raising the flag as I'm hopping it will get fixed eventually.
By the way, JC submitted a fix for the debug version here:
https://github.com/commontk/PythonQt/commit/56cdf6c
QMake supports all platforms that are supported for Qt, which includes all versions of Visual Studio. Just run qmake in a command shell with the correct VS environment (vcvarsall.bat amd64 in your case). Details on qmake are in the Qt docs.
Oh, somehow I didn't get that qmake would work with VS. So I'm guessing this should do it:
right?
Yes, or if you need a solution/vcprojs:
qmake -tp vc -r PythonQt.pro
There is some ambiguity using VS 2010, since I have to recompile Python27 do I simply override the default installed Python27.lib in C:/Python27/Libs ?
I realized the env variables need to be set... I tried the default qmake/nmake and I get this:
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\amd64\cl.EXE"' : return code '0x2'
with the qmake -tp vc -r PythonQt.pro the project is generated but has few mistakes like pyhton26.lib... easy fix... and include src folder is missing from some config as well.
Even with the best intentions I still cant get PythonQt to run in debug...