PDA

View Full Version : compile plugin with msvc??



tentakel
4th May 2010, 08:03
hello,

i want to create a custom widget an use it via drag and drop in qt creator.

i found out how to create a custom widget and i added the compiled *.dll to the qt creator 4.6.
but now i have the follwing error in the plugin overview:
need "windows msvc release full-config" instead of "windows mingw release full-config"
-> loading has failed!!!!!!!

i suppose this means the qt creator is built with msvc compiler and is not compatible to the plugin which is - for sure - compiled with mingw.

how to compile the plugin with msvc compiler or rather Visual Studio????

Any field reports???

faldzip
4th May 2010, 08:59
1. Install Visual Studio (you can try Express Edition)

2. Get the Qt libraries for MSVC (there are only for 2008 version) or get the sources and compile Qt from sources with MSVC (that's simple: open MSVC command prompt, get to the dir where you extracted sources - something like qt-everywhere-4.6.2, type:


configure

answer to some questions, wait for a while (half an hour?), after it finished type:


nmake

and wait for a longer while (4 hours?)
and you have Qt compiled from sources :]

3. If you have .pro file to your project then you have 2 ways:
a) open cmd line and type (in dir where your .pro file is):


qmake -tp vc

this will generate .vcproj file - Project file for MSVC - open it and build it.
b) open visual studio command prompt and type (in dir where your .pro file is):


qmake CONFIG+=release
nmake


Both options will work only if you have Qt Libriaries compiled with MSVC and PATH points to qmake from this version of Qt (with spec set accordingly to your MSVC version, if not then you have to use -spec switch in qmake calls - check it in Qt Assistant).

tentakel
4th May 2010, 13:47
many thanks to faldżip,

now i have got an idea what to do.

......but my first try doesn't work.
so one more question.

i installed the vs2008 and the qt libraries for vs2008.

now i want to process step 3.

In 3a:
it says:
Warning: No Resources in 'icons.qrc'

In 3b:
It says:
NMAKE : fatal error U1073: "../../../Programme/Qt/2010.02.1/qt/mkspecs/win32-g++
/qmake.conf" konnte nicht erstellt werden (----->not built)
Stop.

what do you mean with:
Both options will work only if you have Qt Libriaries compiled with MSVC and PATH points to qmake from this version of Qt (with spec set accordingly to your MSVC version, if not then you have to use -spec switch in qmake calls - check it in Qt Assistant).


Any ideas??????

faldzip
4th May 2010, 15:07
Since you've installed Qt for VS2008 you have now 2 different Qt Libraries in your system - for MinGW (installed with Qt Creator previously) and for VS2008.
Now, when you type qmake which qmake is used? As I see in
[quote]
NMAKE : fatal error U1073: "../../../Programme/Qt/2010.02.1/qt/mkspecs/win32-g++
/qmake.conf" konnte nicht erstellt werden (----->not built)
[/qmake]
it is your MinGW qmake. Type the full path to the right qmake.exe (where you have installed Qt for VS2008). Or check PATH environment variable and set remove path to MinGW Qt installation. Or just uninstall Qt SDK (as I assume that's what you have installed first) and install standalone Qt Creator - it will then use your VS compiler (MSVC).

tentakel
4th May 2010, 15:40
hello faldżip ,

i am on a different system without the previously installed qt creator. i have only installed vc2008 and the qt libarries for vc2008.



by the way:
some notes to 3a:
Warning: No Resources in 'icons.qrc'

i added all the files which are created by the qt creator to the qrc file.
<RCC>
<qresource prefix="/">
<file>ui_testcustom.h</file>
<file>icons.qrc</file>
<file>Makefile</file>
<file>Makefile.Debug</file>
<file>Makefile.Release</file>
<file>testcustom.cpp</file>
<file>testcustom.h</file>
<file>testcustom.pri</file>
<file>TestCustom.pro</file>
<file>TestCustom.pro.user</file>
<file>testcustom.ui</file>
<file>testcustomplugin.cpp</file>
<file>testcustomplugin.h</file>
</qresource>
</RCC>

and executed in cmd: qmake -tp vc
this is now succesful and the VC++ Project File is generated.

after opening the vc++ project file, the vc++ project opens in VC2008,
but,...............the project in vc++ lists additionally the following files moc_testcustom.cpp, moc_testcustompluginand.cpp qrc_icons.cpp.
these files are not generated by qmake -tp vc.

i deleted all the moc_XXX and qrc_XXX files in the project.
compiling the vc++ project fails with "fatal error C1083: Datei (Include) kann nicht geöffnet werden: (--> could not open include file) "QDesignerCustomWidgetInterface": No such file or directory"
perhaps the qt library is not part of VC2008.

so, any ideas????

faldzip
4th May 2010, 17:44
hello faldżip ,

i am on a different system without the previously installed qt creator. i have only installed vc2008 and the qt libarries for vc2008.



by the way:
some notes to 3a:
Warning: No Resources in 'icons.qrc'

i added all the files which are created by the qt creator to the qrc file.
<RCC>
<qresource prefix="/">
<file>ui_testcustom.h</file>
<file>icons.qrc</file>
<file>Makefile</file>
<file>Makefile.Debug</file>
<file>Makefile.Release</file>
<file>testcustom.cpp</file>
<file>testcustom.h</file>
<file>testcustom.pri</file>
<file>TestCustom.pro</file>
<file>TestCustom.pro.user</file>
<file>testcustom.ui</file>
<file>testcustomplugin.cpp</file>
<file>testcustomplugin.h</file>
</qresource>
</RCC>


delete this icons.qrc file. As I can see you don't need this at all.



and executed in cmd: qmake -tp vc
this is now succesful and the VC++ Project File is generated.

after opening the vc++ project file, the vc++ project opens in VC2008,
but,...............the project in vc++ lists additionally the following files moc_testcustom.cpp, moc_testcustompluginand.cpp qrc_icons.cpp.
these files are not generated by qmake -tp vc.

i deleted all the moc_XXX and qrc_XXX files in the project.
compiling the vc++ project fails with "fatal error C1083: Datei (Include) kann nicht geöffnet werden: (--> could not open include file) "QDesignerCustomWidgetInterface": No such file or directory"
perhaps the qt library is not part of VC2008.

so, any ideas????
Do you have "CONFIG += designer plugin" in your .pro file (read Custom Widget Plugin Example in Qt Assistant)? Do you have QTDIR envirnoment variable set? Check if Qt include paths and libs are set in Visual Studio project properties.

moc_xxx files are generated by MOC - meta-object compiler - tool which is a part of Qt.

But surely your previous error from 3b. was cause by wrong mkspec. Remove all files which are not needed (left only .h .cpp .pro) and rerun qmake. If the error still exists delete Makefiles and type:


qmake -spec win32-msvc2008

And I've already told you to read about spec (QMAKESPEC) in Qt Assistant. If you would read it then you would know that this:


.../qt/mkspecs/win32-g++/...

is used with MinGW under Windows.

tentakel
6th May 2010, 14:04
hello faldżip,

let me first say "thank you for your help", so far.
unfortunately i have several problems generating the plugin.

but let me first tell you my proceeding:
1. deleted all makefiles.
2. opened qt prompt
3. in project folder: qmake -spec win32-msvc2008 (now i have new makefiles with the correct path to qt and msvc)
4. qmake -tp vc (generating vcproj)

5. qmake CONFIG+=release
6. nmake
or
5. open vcproj file & compile release version

the plugin *.dll is generated without any errors. therefore all neccessary files were generated (moc_, ...)

then..........

A. switching the system (another pc) to the qt sdk
B. adding the *.dll to qt designer
C. the custom widget appears and can be placed
D. on the form only a rectangle appears as custom widget without buttons placed as before
E. try to build it: error: qt wants the mycustom.cpp and mycustom.h file of the custom plugin in its project folder
F. i copy the cpp and h file of the custom plugin in the project folder
G. start Building with my custom widget "MyCustom" ---------error--------->
- C:/............../ui_mainwindow.h:43: undefined reference to `MyCustom::MyCustom(QWidget*)'
- :-1: error: collect2: ld returned 1 exit status

do you think my makefiles are still buggy????

i suppose the *.dll refers to the qt library of the second system.
or am i doing sth else wrong???