[fox@localhost qt]$ make
g++ -c -pipe -Wall -W -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpr
o -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/lib/qt3//include
-o helloqt.o helloqt.cpp
g++ -o qt helloqt.o -L/usr/X11R6/lib -lXext -lX11 -lm
helloqt.o(.text+0x2a): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
helloqt.o(.text+0x50): In function `main':
: undefined reference to `QString::QString[in-charge](char const*)'
helloqt.o(.text+0x6e): In function `main':
: undefined reference to `QLabel::QLabel[in-charge](QString const&, QWidget*, ch
ar const*, unsigned)'
helloqt.o(.text+0x84): In function `main':
: undefined reference to `QString::shared_null'
helloqt.o(.text+0x8e): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloqt.o(.text+0x9a): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
helloqt.o(.text+0xad): In function `main':
: undefined reference to `QApplication::exec()'
helloqt.o(.text+0xb7): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
helloqt.o(.text+0xd6): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
helloqt.o(.text+0x104): In function `main':
: undefined reference to `QString::shared_null'
helloqt.o(.text+0x10e): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference to `QGList::clea r()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference to `QGList::~QG List [in-charge]()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference to `QGList::~QG List [in-charge deleting]()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference to `QPtrCollect ion::newItem(void*)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference to `QGList::com pareItems(void*, void*)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference to `QGList::rea d(QDataStream&, void*&)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference to `QGList::wri te(QDataStream&, void*) const'
helloqt.o(.gnu.linkonce.r._ZTI6QGList+0x8): undefined reference to `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] Ошибка 1
[fox@localhost qt]$
[fox@localhost qt]$ cat helloqt.cpp
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication app (argc, argv);
QLabel *label = new QLabel("Hello qt!", 0);
app.setMainWidget(label);
label -> show();
return app.exec();
}
[fox@localhost qt]$ g++ helloqt.cpp -L/usr/X11R6/lib -lXext -lX11 -lm -lqt-mt
helloqt.cpp:1:26: qapplication.h: No such file or directory
helloqt.cpp:2:20: qlabel.h: No such file or directory
helloqt.cpp: In function `int main(int, char**)':
helloqt.cpp:6: error: `QApplication' undeclared (first use this function)
helloqt.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
helloqt.cpp:6: error: syntax error before `(' token
helloqt.cpp:7: error: `QLabel' undeclared (first use this function)
helloqt.cpp:7: error: `label' undeclared (first use this function)
helloqt.cpp:7: error: syntax error before `(' token
helloqt.cpp:8: error: `app' undeclared (first use this function)
[fox@localhost qt]$
может и не пашет. надо тебе самому посмотреть, где лежать заголовки и прописать путь к ним.
у меня, например, они лежат не в /usr/lib/qt3/include, а в /usr/inlude/qt3
если не найдёшь заголовки -- то их надо поставить. но это совсем другая история
Они у меня в /usr/lib/qt3/includes
Пробовал ставить qt-3.3.3 и компилировать g++ c "-extra-inkludes=/usr/lib/qt3/include" - то же самое, не пашет. Глючит зверюга
То же самое: либо какую-то тарабарщину, либо не узнаёт классы qt. А инклюде находит, иначе бы написал, что не может найти файл. Сейчас времени немного, попробую сам ещё раз всё собрать.
Очевидно лагает gcc: попробовал компайлить с SDL - проблемы в заголовочном файле stdio.h. Gjckt ecnfyjdrb 3.4.1(вместо 3.3.2). Вывод ошибок стал более вразумительный.
Доброе утро.
Не уверен в правильности синтаксиса:
-I/usr/lib/qt3//include
Два слэша-то зачем?
Слеши нипричём. Можно ставить хоть десять. А команды генерировал qmake, просто разработчики Mandrake при сборке в конечных директориях науказывали /, а во время сборки автоматически добавился второй.
Для успешной компиляции надо было добавлять '-lqt-mt'(или '-lqt')