Модераторы: xvr
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> не компилируются *cpp, использ. qt3, g++ выдаёт странные ошибки 
:(
    Опции темы
powerfox
Дата 13.10.2005, 18:02 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


I wanna fork()
****


Профиль
Группа: Комодератор
Сообщений: 3990
Регистрация: 1.10.2005
Где: Санкт-Петербург

Репутация: 5
Всего: 97



Код

#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();
}


Код

g++ helloqt.cpp -I /usr/lib/qt3/include/ -L /usr/lib/qt3/lib
/home/fox/tmp/cc49C8Ab.o(.text+0x135): In function `main':
: undefined reference to `QApplication::QApplication(int&, char**)'
/home/fox/tmp/cc49C8Ab.o(.text+0x148): In function `main':
: undefined reference to `QString::QString(char const*)'
/home/fox/tmp/cc49C8Ab.o(.text+0x18d): In function `main':
: undefined reference to `QLabel::QLabel(QString const&, QWidget*, char const*,
unsigned int)'
/home/fox/tmp/cc49C8Ab.o(.text+0x1f8): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
/home/fox/tmp/cc49C8Ab.o(.text+0x218): In function `main':
: undefined reference to `QApplication::exec()'
/home/fox/tmp/cc49C8Ab.o(.text+0x225): In function `main':
: undefined reference to `QApplication::~QApplication()'
/home/fox/tmp/cc49C8Ab.o(.text+0x241): In function `main':
: undefined reference to `QApplication::~QApplication()'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x1e): In function `QSt                                            ring::~QString()':
: undefined reference to `QString::shared_null'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x2d): In function `QSt                                            ring::~QString()':
: undefined reference to `QStringData::deleteSelf()'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference t                                            o `QGList::clear()'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference                                             to `QGList::~QGList()'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference                                             to `QGList::~QGList()'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference                                             to `QPtrCollection::newItem(void*)'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference                                             to `QGList::compareItems(void*, void*)'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference                                             to `QGList::read(QDataStream&, void*&)'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference                                             to `QGList::write(QDataStream&, void*) const'
/home/fox/tmp/cc49C8Ab.o(.gnu.linkonce.r._ZTI6QGList+0x8): undefined reference t                                            o `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status

smile
До этого использовал g++-3.3.2 - комп. не мог найти определения классов qt. Сейчас поставил 3.4.1 - ответ компилятора стал длинее.
Такbtже проблемы с SDL.


--------------------
user posted image
PM WWW   Вверх
srd
Дата 13.10.2005, 18:08 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Нереварин
**


Профиль
Группа: Участник Клуба
Сообщений: 951
Регистрация: 30.8.2003
Где: Владивосток

Репутация: нет
Всего: 49



Указание каталога с библиотеками Qt с помощью клача -L недостаточно. Следует ещё с помощью ключа -l указать сами библиотеки smile В этом же туториале, который ты смотришь, ниже по тексту написано, как сгенерировать правильный makefile с помощью qmake.


--------------------
Не смей читать мою подпись!!!
PM MAIL Jabber   Вверх
powerfox
Дата 13.10.2005, 18:14 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


I wanna fork()
****


Профиль
Группа: Комодератор
Сообщений: 3990
Регистрация: 1.10.2005
Где: Санкт-Петербург

Репутация: 5
Всего: 97



Цитата(srd @ 13.10.2005, 18:08)
Указание каталога с библиотеками Qt с помощью клача -L недостаточно. Следует ещё с помощью ключа -l указать сами библиотеки smile В этом же туториале, который ты смотришь, ниже по тексту написано, как сгенерировать правильный makefile с помощью qmake.

Тогда делает так:
Код

[fox@localhost qt]$ qmake -project
[fox@localhost qt]$ qmake
[fox@localhost qt]$ make
g++ -c -pipe -Wall -W -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro -DQT_NO_DEBUG  -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/lib/qt3//include -o helloqt.o helloqt.cpp
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
g++  -o qt helloqt.o   -L/usr/X11R6/lib -lXext -lX11 -lm
helloqt.o(.text+0x32): In function `main':
: undefined reference to `QApplication::QApplication(int&, char**)'
helloqt.o(.text+0x41): In function `main':
: undefined reference to `QString::QString(char const*)'
helloqt.o(.text+0x6d): In function `main':
: undefined reference to `QLabel::QLabel(QString const&, QWidget*, char const*, unsigned int)'
helloqt.o(.text+0x7f): In function `main':
: undefined reference to `QString::shared_null'
helloqt.o(.text+0x89): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloqt.o(.text+0x95): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
helloqt.o(.text+0xa8): In function `main':
: undefined reference to `QApplication::exec()'
helloqt.o(.text+0xb2): In function `main':
: undefined reference to `QApplication::~QApplication()'
helloqt.o(.text+0xe4): In function `main':
: undefined reference to `QApplication::~QApplication()'
helloqt.o(.text+0x10c): In function `main':
: undefined reference to `QString::shared_null'
helloqt.o(.text+0x116): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference to `QGList::clear()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference to `QGList::~QGList()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference to `QGList::~QGList()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference to `QPtrCollection::newItem(void*)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference to `QGList::compareItems(void*, void*)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference to `QGList::read(QDataStream&, void*&)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference to `QGList::write(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


А если вручную
Код

g++ helloqt.cpp -I /usr/lib/qt3/include/ -L /usr/lib/qt3/lib/ -lqt-mt
- работает
Спасибо. Про Makefile посмотрю, что дальше пишут.


--------------------
user posted image
PM WWW   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "С/С++: Программирование под Unix/Linux"
xvr
  • Проставьте несколько ключевых слов темы, чтобы её можно было легче найти.
  • Не забывайте пользоваться кнопкой "Код".
  • Вопросы мобильной разработки тут
  • Телепатов на форуме нет! Задавайте чёткий, конкретный и полный вопрос. Указывайте полностью ошибки компилятора и компоновщика.
  • Новое сообщение должно иметь прямое отношение к разделу форума. Флуд, флейм, оффтопик запрещены.
  • Категорически запрещается обсуждение вареза, "кряков", взлома программ и т.д.

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, xvr.

 
 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C/C++: Программирование под Unix/Linux | Следующая тема »


 




[ Время генерации скрипта: 0.0442 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.