Kompilierfehler in MinGW und VC++6.0

Alles rund um die Programmierung mit Qt
Antworten
scooter
Beiträge: 11
Registriert: 7. März 2005 15:29

Kompilierfehler in MinGW und VC++6.0

Beitrag von scooter »

Ich habe ein Kompilierproblem, bei dem ich nicht mehr weiter weiß; einen Fehler kann ich nicht erkennen.

Ich habe zum einen Qt 4.4.1 OpenSource Windows mit dem richtigen MinGW (ich glaube, das war Version 2.3.7) und auch Qt 4.4.0 Evaluation Version mit vorher eingerichtetem Visual C++ 6.0 installiert.

Bei beiden tauchen am jeweiligen Qt-Prompt nach

Code: Alles auswählen

qmake -project
qmake gotocell.pro
make bzw. nmake
eine Reihe von Fehlern auf, und das, obwohl ich exakt der Anleitung im Buch "C++ GUI Programming with Qt 4" im Kapitel "Rapid Dialog Design" gefolgt bin. Ich habe das Widget erstellt, das Layout festgelegt und die Tab-Reihenfolge geprüft. Mehr erstmal nicht.

Die Datei gotocelldialog.ui hat folgenden Inhalt:

Code: Alles auswählen

<ui version="4.0" >
 <class>GoToCellDialog</class>
 <widget class="QMainWindow" name="GoToCellDialog" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>224</width>
    <height>113</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>Go To Cell</string>
  </property>
  <widget class="QWidget" name="centralwidget" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>21</y>
     <width>224</width>
     <height>73</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout" >
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout" >
      <item>
       <widget class="QLabel" name="label" >
        <property name="text" >
         <string>&Cell location:</string>
        </property>
        <property name="buddy" >
         <cstring>lineEdit</cstring>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLineEdit" name="lineEdit" />
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_2" >
      <item>
       <spacer name="horizontalSpacer" >
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>
        </property>
        <property name="sizeHint" stdset="0" >
         <size>
          <width>40</width>
          <height>20</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
       <widget class="QPushButton" name="okButton" >
        <property name="enabled" >
         <bool>false</bool>
        </property>
        <property name="text" >
         <string>OK</string>
        </property>
        <property name="default" >
         <bool>true</bool>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QPushButton" name="cancelbutton" >
        <property name="text" >
         <string>Cancel</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>0</y>
     <width>224</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>94</y>
     <width>224</width>
     <height>19</height>
    </rect>
   </property>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>
Die main.cpp hat diesen Inhalt:

Code: Alles auswählen

#include <QApplication>
#include <QDialog>
#include "ui_gotocelldialog.h"
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Ui::GoToCellDialog ui;
    QDialog *dialog = new QDialog;
    ui.setupUi(dialog);
    dialog->show();
    return app.exec();
}
Alles, so wie es im Buch steht (Errata zum buch gibt es für dieses Beispiel nicht).

Als Fehlermeldung kommt beispielsweise in der Evaulation Version:

Code: Alles auswählen

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0

Copyright (C) Microsoft Corp 1988-1998. All rights reserved.



	NMAKE -f Makefile.Debug

	cl -c -nologo -Zm200 -Zi -MDd -GR -GX -W3 -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Programme\Qt\4.4.0\include\QtCore" -I"c:\Programme\Qt\4.4.0\include\QtCore" -I"c:\Programme\Qt\4.4.0\include\QtGui" -I"c:\Programme\Qt\4.4.0\include\QtGui" -I"c:\Programme\Qt\4.4.0\include" -I"." -I"c:\Programme\Qt\4.4.0\include\ActiveQt" -I"debug" -I"." -I"c:\Programme\Qt\4.4.0\mkspecs\win32-msvc" -Fodebug\ @C:\DOKUME~1\Rainer\LOKALE~1\Temp\nma02252.

main.cpp

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(629) : error C2059: syntax error : '?'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(629) : error C2065: '_Y' : undeclared identifier

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(629) : error C2275: '_A' : illegal use of this type as an expression

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(629) : error C2143: syntax error : missing ',' before ')'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(631) : error C2951: template declarations are only permitted at global or namespace scope

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(632) : error C2976: '_Tree' : too few template arguments

        C:\Programme\Microsoft Visual Studio\VC98\include\xtree(602) : see declaration of '_Tree'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(633) : error C2143: syntax error : missing ',' before '<='

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(633) : error C2433: 'bool' : 'inline' not permitted on data declarations

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(633) : error C2059: syntax error : 'operator <op>'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(635) : error C2143: syntax error : missing ')' before '{'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(635) : error C2059: syntax error : '{'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(635) : error C2143: syntax error : missing ';' before '{'

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(635) : error C2447: missing function header (old-style formal list?)

C:\Programme\Microsoft Visual Studio\VC98\include\xtree(636) : error C2954: template definitions cannot nest

C:\Programme\Microsoft Visual Studio\VC98\include\map(44) : error C2039: 'reference' : is not a member of '_A'

        C:\Programme\Microsoft Visual Studio\VC98\include\xtree(632) : see declaration of '_A'

        C:\Programme\Microsoft Visual Studio\VC98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

C:\Programme\Microsoft Visual Studio\VC98\include\map(44) : error C2146: syntax error : missing ';' before identifier '_Tref'

        C:\Programme\Microsoft Visual Studio\VC98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

C:\Programme\Microsoft Visual Studio\VC98\include\map(44) : error C2501: '_Tref' : missing storage-class or type specifiers

        C:\Programme\Microsoft Visual Studio\VC98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

C:\Programme\Microsoft Visual Studio\VC98\include\map(48) : error C2040: 'reference' : ' &' differs in levels of indirection from 'int'

        C:\Programme\Microsoft Visual Studio\VC98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

C:\Programme\Microsoft Visual Studio\VC98\include\map(92) : error C2143: syntax error : missing ';' before '['

        C:\Programme\Microsoft Visual Studio\VC98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

C:\Programme\Microsoft Visual Studio\VC98\include\map(92) : error C2501: '_Tref' : missing storage-class or type specifiers

        C:\Programme\Microsoft Visual Studio\VC98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

.\main.cpp(9) : error C2664: 'setupUi' : cannot convert parameter 1 from 'class QDialog *' to 'class QMainWindow *'

        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

NMAKE : fatal error U1077: 'cl' : return code '0x2'

Stop.

NMAKE : fatal error U1077: '"C:\Programme\Microsoft Visual Studio\VC98\bin\NMAKE

.EXE"' : return code '0x2'

Stop.
Was zum Teufel geht hier falsch? Ich habe nichts an den sonstigen Einstellungen geändert.
Christian81
Beiträge: 7319
Registriert: 26. August 2004 14:11
Wohnort: Bremen
Kontaktdaten:

Beitrag von Christian81 »

Obwohl mir der Fehler selbst nichts sagt - msvc6 ist alt und dass qt4.4 noch damit kompiliert (zumindest zum Teil) kommt eher daher dass der msvc6 noch nicht explizit ausgebaut wurde. Nimm was neueres wie msvc2005 oder 2008 (Express)
MfG Christian

'Funktioniert nicht' ist keine Fehlerbeschreibung
scooter
Beiträge: 11
Registriert: 7. März 2005 15:29

Beitrag von scooter »

Bei Trolltech gibt es eine Version speziell für VC++ 6.0, wie auch für VS2005 und VS2008.

Das Problem liegt offenbar nicht an Qt, denn qmake zeigt keine Probleme. Da Trolltech VC++ 6.0 offiziell voll unterstützt, könnte die Ursache vielleicht nur bei VC++ zu suchen sein.

Okay, VC++ ist nicht mehr das Neueste, aber viele nutzen es noch.

Wie steht es übrigens mit VS 2008 Express? Wird dies von Qt 4.4.x voll unterstützt oder muss man Abstriche hinnehmen (oder etwas "hinbiegen")? Hat jemand hier Erfahrung damit?
Christian81
Beiträge: 7319
Registriert: 26. August 2004 14:11
Wohnort: Bremen
Kontaktdaten:

Beitrag von Christian81 »

vs2008 funktioniert mit 4.4 ohne Probleme.
kompiliert ein nicht-qt Programm?
MfG Christian

'Funktioniert nicht' ist keine Fehlerbeschreibung
Selur
Beiträge: 27
Registriert: 19. Juni 2008 22:07

Beitrag von Selur »

Kompiliere hier auch mit dem VS 2008 Express compiler ohne Probleme, einzig anfang etwas nervig, ist dass man sich erstmal QT selber mit VC kompilieren muss. ;)
scooter
Beiträge: 11
Registriert: 7. März 2005 15:29

Beitrag von scooter »

@Selur:

Ich habe mir jetzt VS 2008 Express auf den Rechner getan und bekam bei der Installation eine Meldung, das SQL nicht installiert werden konnte. Warum auch immer. Auf meinem System ist bereits MySQL drauf (wegen XAMPP) und dort als Dienst eingerichtet. Stört sich VS daran?

Dann habe ich die QT 4.4.0 Evaluation draufgetan und hatte das Phänomen, dass ich in der Listbox der auszuwählenden Komponenten die drei VS betreffenden nicht auswählen konnte, obwohl die Einträge als aktiv, also anklickbar, ausgezeichnet waren. Das habe ich aber als geringeres Übel angesehen, weil ich Kleinstcode problemlos kompilieren konnte.

Vermutlich muss ich Qt erst mit VS kompilieren (wie du es getan hast), aber wie genau mache ich das?

Daher dürfte auch das Problem herrühren, dass ich zwar im Editor erstellten Code kompilieren kann, mit dem Qt Designer erzeugte .ui-Dateien aber nicht.
Selur
Beiträge: 27
Registriert: 19. Juni 2008 22:07

Beitrag von Selur »

Hab bei mir kein sql installiert (eventuell wieder deinstalliert), scheint also nicht so wichtig zu sein. :)
Vermutlich muss ich Qt erst mit VS kompilieren (wie du es getan hast), aber wie genau mache ich das?
Bin mir nicht mehr ganz sicher, soweit ich mich aber entsinne bin ich beim letzen Mal dem Tutorial bei http://www.coding-pur.com/showthread.ph ... 66#pid1366 gefolgt zum Compilieren der Sourcen. :)
Für mein aktuelles Projekt hab ich dann die Includes&Co alle dementsprechend umgeändert, dass sie auch die VC libaries laden. Nutze Eclipse und da wird es dann noch etwas umständlicher, weil es leider kein extra VC Plugin gibt, sondern nur eins für MinGW, was aber auf Grund des langen linkings nicht in Frage kommt für mich. (1min kompilieren oder 6 ist schon ein Unterschied ;))

Cu Selur
scooter
Beiträge: 11
Registriert: 7. März 2005 15:29

Beitrag von scooter »

Den Link gibt es nicht mehr. Hast du was Aktuelleres?
Antworten