PDA

View Full Version : I can't compile program which I have wrote in windows



newplayer
7th July 2008, 20:21
!!! This program has got polish names :) Sry

for example - file 'main.cpp':


#include <QtGui>
#include "mojeokno.h"

int main(int argc, char *argv[])
{
QApplication aplikacja(argc, argv);
MojeOkno okno;
okno.show();
return aplikacja.exec();
}


file 'mojeokno.h':


#include <QtGui>
#include "ui_okno.h"

#ifndef _MOJEOKNO_H_
#define _MOJEOKNO_H_

class MojeOkno: public QMainWindow
{
Q_OBJECT

public:
MojeOkno();
~MojeOkno(){};
private:
QString nazwapliku;

QTextEdit *poletekstowe;

QMenu *menu;
QAction *menuNew;
QAction *menuOpen;
QAction *menuSave;
QAction *menuSaveAs;
QAction *menuQuit;

QToolBar *toolBar;

private slots:
void New ();
void Open ();
void Save ();
void SaveAs ();
};


#endif



file 'ui_okno.h' - this file I created in Qt Designer in windows:


/************************************************** ******************************
** Form generated from reading ui file 'okno.ui'
**
** Created: Mon 7. Jul 20:25:54 2008
** by: Qt User Interface Compiler version 4.4.0
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
************************************************** ******************************/

#ifndef UI_OKNO_H
#define UI_OKNO_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QStatusBar>
#include <QtGui/QTextEdit>
#include <QtGui/QToolBar>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>

QT_BEGIN_NAMESPACE

class Ui_Okno
{
public:
QAction *actionOtworz;
QAction *actionZapisz;
QAction *actionNowy;
QAction *actionZapiszjako;
QAction *actionWyjscie;
QWidget *centralwidget;
QVBoxLayout *verticalLayout;
QTextEdit *poletekstowe;
QMenuBar *menubar;
QMenu *menuPlik;
QStatusBar *statusbar;
QToolBar *toolBar;

void setupUi(QMainWindow *Okno)
{
if (Okno->objectName().isEmpty())
Okno->setObjectName(QString::fromUtf8("Okno"));
Okno->resize(600, 400);
actionOtworz = new QAction(Okno);
actionOtworz->setObjectName(QString::fromUtf8("actionOtworz"));
QIcon icon;
icon.addPixmap(QPixmap(QString::fromUtf8(":/images/open.png")), QIcon::Normal, QIcon::Off);
actionOtworz->setIcon(icon);
actionZapisz = new QAction(Okno);
actionZapisz->setObjectName(QString::fromUtf8("actionZapisz"));
QIcon icon1;
icon1.addPixmap(QPixmap(QString::fromUtf8(":/images/save.png")), QIcon::Normal, QIcon::Off);
actionZapisz->setIcon(icon1);
actionNowy = new QAction(Okno);
actionNowy->setObjectName(QString::fromUtf8("actionNowy"));
QIcon icon2;
icon2.addPixmap(QPixmap(QString::fromUtf8(":/images/new.png")), QIcon::Normal, QIcon::Off);
actionNowy->setIcon(icon2);
actionZapiszjako = new QAction(Okno);
actionZapiszjako->setObjectName(QString::fromUtf8("actionZapiszjako"));
actionWyjscie = new QAction(Okno);
actionWyjscie->setObjectName(QString::fromUtf8("actionWyjscie"));
centralwidget = new QWidget(Okno);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
centralwidget->setGeometry(QRect(0, 55, 600, 326));
verticalLayout = new QVBoxLayout(centralwidget);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
poletekstowe = new QTextEdit(centralwidget);
poletekstowe->setObjectName(QString::fromUtf8("poletekstowe"));

verticalLayout->addWidget(poletekstowe);

Okno->setCentralWidget(centralwidget);
menubar = new QMenuBar(Okno);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 600, 21));
menuPlik = new QMenu(menubar);
menuPlik->setObjectName(QString::fromUtf8("menuPlik"));
Okno->setMenuBar(menubar);
statusbar = new QStatusBar(Okno);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
statusbar->setGeometry(QRect(0, 381, 600, 19));
Okno->setStatusBar(statusbar);
toolBar = new QToolBar(Okno);
toolBar->setObjectName(QString::fromUtf8("toolBar"));
toolBar->setGeometry(QRect(0, 21, 600, 34));
Okno->addToolBar(Qt::TopToolBarArea, toolBar);

menubar->addAction(menuPlik->menuAction());
menuPlik->addAction(actionOtworz);
menuPlik->addAction(actionZapisz);
menuPlik->addAction(actionNowy);
menuPlik->addAction(actionZapiszjako);
menuPlik->addSeparator();
menuPlik->addAction(actionWyjscie);
toolBar->addAction(actionOtworz);
toolBar->addAction(actionZapisz);
toolBar->addAction(actionNowy);

retranslateUi(Okno);

QMetaObject::connectSlotsByName(Okno);
} // setupUi

void retranslateUi(QMainWindow *Okno)
{
Okno->setWindowTitle(QApplication::translate("Okno", "MainWindow", 0, QApplication::UnicodeUTF8));
actionOtworz->setText(QApplication::translate("Okno", "Otw\303\263rz", 0, QApplication::UnicodeUTF8));
actionZapisz->setText(QApplication::translate("Okno", "Zapisz", 0, QApplication::UnicodeUTF8));
actionNowy->setText(QApplication::translate("Okno", "Nowy", 0, QApplication::UnicodeUTF8));
actionZapiszjako->setText(QApplication::translate("Okno", "Zapisz jako", 0, QApplication::UnicodeUTF8));
actionWyjscie->setText(QApplication::translate("Okno", "Wyj\305\233cie", 0, QApplication::UnicodeUTF8));
menuPlik->setTitle(QApplication::translate("Okno", "Plik", 0, QApplication::UnicodeUTF8));
toolBar->setWindowTitle(QApplication::translate("Okno", "toolBar", 0, QApplication::UnicodeUTF8));
} // retranslateUi

};

namespace Ui {
class Okno: public Ui_Okno {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_OKNO_H



I have also other files but these 3. files are the most important because I have mistakes:


ui_okno.h:28: error: expected constructor, destructor, or type conversion before ‘class’
ui_okno.h:125: error: expected class-name before ‘{’ token
mojeokno.h:7: error: expected constructor, destructor, or type conversion before ‘class’
main.cpp: In function ‘int main(int, char**)’:
main.cpp:7: error: ‘MojeOkno’ was not declared in this scope
main.cpp:7: error: expected `;' before ‘okno’
main.cpp:8: error: ‘okno’ was not declared in this scope
make: *** [main.o] Błąd 1



Why? :( In windows everything was ok. :( :(

jacek
7th July 2008, 20:45
Do you use qmake?

newplayer
8th July 2008, 06:53
yes :



[jogurtcytrynowy@localhost katalog]$ /usr/lib/qt4/bin/qmake -project
[jogurtcytrynowy@localhost katalog]$ /usr/lib/qt4/bin/qmake
[jogurtcytrynowy@localhost katalog]$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include -I. -I. -I. -o main.o main.cpp
ui_okno.h:28: error: expected constructor, destructor, or type conversion before ‘class’
ui_okno.h:125: error: expected class-name before ‘{’ token
mojeokno.h:7: error: expected constructor, destructor, or type conversion before ‘class’
main.cpp: In function ‘int main(int, char**)’:
main.cpp:7: error: ‘MojeOkno’ was not declared in this scope
main.cpp:7: error: expected `;' before ‘okno’
main.cpp:8: error: ‘okno’ was not declared in this scope
make: *** [main.o] Błąd 1

jacek
8th July 2008, 12:33
What does "/usr/lib/qt4/bin/qmake -version" output?

Remove QT_BEGIN_NAMESPACE and QT_END_NAMESPACE from ui_okno.h and it should compile.

newplayer
8th July 2008, 13:06
thx you very much - now it works !!!!!!!!! XD

newplayer
8th July 2008, 15:27
Do you know why it works in linux without QT_BEGIN_NAMESPACE and QT_END_NAMESPACE ? Is it a mistake in Qt Designer in windows ?

jacek
8th July 2008, 17:13
Do you know why it works in linux without QT_BEGIN_NAMESPACE and QT_END_NAMESPACE ?
You might be using earlier Qt version. To be sure, answer the question from my previous post.

jpn
8th July 2008, 18:01
Do you know why it works in linux without QT_BEGIN_NAMESPACE and QT_END_NAMESPACE ? Is it a mistake in Qt Designer in windows ?
No, the reason is that you ran "qmake -project" when there were generated intermediate files. Only .ui files should be listed in .pro instead of generated ui_*.h (or any other generated files for that matter). You should run "qmake -project" only once in the beginning of the project, not always when you compile.

newplayer
8th July 2008, 20:28
I compiled 'ui_window.h' which I created in windows. Now I am compiling 'window.ui' and everything is ok - thx you both very much.
I clicked 'thanks button' but I think it doesn't work. :/

jacek
8th July 2008, 23:23
I clicked 'thanks button' but I think it doesn't work. :/
I've noticed it. It will be fixed by the end of the month. There's no summer for me yet :(