Russian Qt Forum
Май 03, 2024, 06:31 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: [Qt 4.7 SDK] Проблема с dll  (Прочитано 2540 раз)
Preveter
Гость
« : Октябрь 16, 2011, 18:34 »

Не получается использовать скомпилированную мной dll в программе.
 При линковке программы выдаётся ошибка:

release/widget.o:widget.cpp:(.text+0x3a8): undefined reference to `_imp___ZN5MIBot8makeTurnEPiS0_S0_PS0_S0_'
 release/widget.o:widget.cpp:(.text+0x48b): undefined reference to `_imp___ZN5MIBotC1Ev'
 release/widget.o:widget.cpp:(.text+0x54f): undefined reference to `_imp___ZN5MIBotC1Ev'
 collect2: ld returned 1 exit status


 Причём библиотека компилируется без ошибок.

Вот код:

dll:

 mibot.pro:

Код:
TEMPLATE = lib
CONFIG += shared
 
DEFINES += D_SHARED_LIB
 
VERSION = 1.0.0
TARGET = MaxItBot
DLLDESTDIR += ../MaxIt/release
DESTDIR = lib
 
HEADERS += \
    mibot.h \
    ddll.h
 
SOURCES += \
    mibot.cpp


ddll.h:

Код:
#ifndef D_DLL
#define D_DLL
#include <QtGlobal>
 
#ifdef D_SHARED_LIB
        #define D_SHARED Q_DECL_EXPORT
#else
        #define D_SHARED Q_DECL_IMPORT
#endif
 
#endif

mibot.h:

Код:
#ifndef MIBOT_H
#define MIBOT_H
#include "ddll.h"
 
class D_SHARED MIBot
{
public:
    MIBot();
    void makeTurn(int*,int*,int*,int**,int*);
    int turn(int,int,int,int,int);
 
    int* curpl,*tx,*ty;
    int* c;
    int** field;
};
 
#endif // MIBOT_H

mibot.cpp

Код:
#include "mibot.h"
MIBot::MIBot()
{
}
void MIBot::makeTurn(int* curplF,int* txF,int* tyF, int** fieldF,int* cF){
    c=cF;
    field=fieldF;
    ty=tyF;
    tx=txF;
    curpl=curplF;
    ...
    for (i=0;i<8;i++) r[i]=turn(0,maxLevel,*tx,i,*curpl^1);
    ...
}
 
int MIBot::turn(int r,int maxLevel,int x,int y,int pl){
    ...
    turn(r,maxLevel,i,y,pl^1);
    ...
    return r;
}

Программа:

 maxit.pro:

Код:
QT       += core gui
CONFIG += qt warn_on
 
TARGET = MaxIt
TEMPLATE = app
 
SOURCES += main.cpp\
        widget.cpp
 
HEADERS  += widget.h
 
DEPENDPATH += dll
INCLUDEPATH += dll
LIBS += -Ldll -LlibMaxItBot

widget.h:

Код:
#ifndef WIDGET_H
#define WIDGET_H
 
#include <QtGui>
#include "mibot.h"
 
class Widget : public QWidget
{
    Q_OBJECT
 
public:
    Widget(QWidget *parent = 0);
    ~Widget();
    ...
    void keyPressEvent(QKeyEvent * event);
    ...
    MIBot bot;
    ...
};


widget.cpp:

Код:
#include "widget.h"
    ...
 
void Widget::keyPressEvent(QKeyEvent *event){
    ...
    if (event->key()==Qt::Key_Return && field[tx][ty]!=0){
        ...
        if (gameMode==2){
            bot.makeTurn(&curpl,&tx,&ty,field,c);
            ...
        }
    }
    ...
}
    ...

main.cpp:

Код:
#include <QtGui/QApplication>
#include "widget.h"
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
 
    return a.exec();
}


В чём дело? Подскажите пожалуйста.
 
Записан
lesav
Частый гость
***
Offline Offline

Сообщений: 235


qnx.org.ru


Просмотр профиля WWW
« Ответ #1 : Октябрь 16, 2011, 18:57 »

Поиск по форуму решает много проблем. К тому ж не создает проблем другим! )))

http://www.prog.org.ru/index.php?topic=19725.msg133474#msg133474
Записан

lesav
Частый гость
***
Offline Offline

Сообщений: 235


qnx.org.ru


Просмотр профиля WWW
« Ответ #2 : Октябрь 16, 2011, 19:01 »

Созданную библиотеку ложите сюда
mibot.pro:
Код:
DESTDIR = lib


А в программе ее ищите не там где положили.
maxit.pro:
Код:
LIBS += -Ldll -LlibMaxItBot
Записан

Preveter
Гость
« Ответ #3 : Октябрь 17, 2011, 18:57 »

lesav, не в том дело... На это есть копирование... Чем я собственно и занимаюсь...
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.059 секунд. Запросов: 23.