Hi, all. I'm writing a dynamic library and an application that uses it.
When I compile the library everything seems to be ok, no error messages. But when I compile the application, linker prints the following message:
undefined reference to dbConnected(QString). dbConnected is a signal in my library.
I have tried many things (qmake && make, generate & link *.prl) but the problem stays the same.
Dynamic Library project file:
#-------------------------------------------------
#
# Project created by QtCreator 2012-07-31T02:34:49
#
#-------------------------------------------------
QT += sql
QT -= gui
TARGET = DatabaseTools
TEMPLATE = lib
DEFINES += DATABASETOOLS_LIBRARY
SOURCES += DatabaseTools.cpp \
DatabaseObject.cpp \
DatabaseQuery.cpp \
DatabaseMutex.cpp \
DatabaseQueryResult.cpp \
DatabaseThread.cpp \
DatabaseQueue.cpp \
DatabaseHandle.cpp
HEADERS += DatabaseTools_global.h \
DatabaseTools.h \
DatabaseObject.h \
DatabaseQuery.h \
DatabaseMutex.h \
DatabaseQueryResult.h \
DatabaseThread.h \
DatabaseQueue.h \
DatabaseHandle.h
INCLUDEPATH += /usr/include/mysql
LIBS += -lmysqlclient
DLLDESTDIR = ../Build
DESTDIR = ../Build
CONFIG += create_prl
#-------------------------------------------------
#
# Project created by QtCreator 2012-07-31T02:34:49
#
#-------------------------------------------------
QT += sql
QT -= gui
TARGET = DatabaseTools
TEMPLATE = lib
DEFINES += DATABASETOOLS_LIBRARY
SOURCES += DatabaseTools.cpp \
DatabaseObject.cpp \
DatabaseQuery.cpp \
DatabaseMutex.cpp \
DatabaseQueryResult.cpp \
DatabaseThread.cpp \
DatabaseQueue.cpp \
DatabaseHandle.cpp
HEADERS += DatabaseTools_global.h \
DatabaseTools.h \
DatabaseObject.h \
DatabaseQuery.h \
DatabaseMutex.h \
DatabaseQueryResult.h \
DatabaseThread.h \
DatabaseQueue.h \
DatabaseHandle.h
INCLUDEPATH += /usr/include/mysql
LIBS += -lmysqlclient
DLLDESTDIR = ../Build
DESTDIR = ../Build
CONFIG += create_prl
To copy to clipboard, switch view to plain text mode
Class header file:
#ifndef DATABASETOOLS_H
#define DATABASETOOLS_H
#include "DatabaseTools_global.h"
#include <QObject>
#include <QPointer>
#include <QStringList>
#include <QMap>
#include <QTimer>
#include "DatabaseHandle.h"
#include "DatabaseQueue.h"
#include "DatabaseThread.h"
#include "DatabaseQuery.h"
#include "DatabaseObject.h"
class DATABASETOOLSSHARED_EXPORT DatabaseTools
: public QObject{
static QMap<QString, QPointer<DatabaseTools> > PointersMap;
DatabaseHandle DbHandle;
DatabaseQueue DbQueue;
QString SessionUserName, SessionPassword;
bool IsDbEmpty;
DatabaseTools
(QString connection_name
);
public:
static QPointer<DatabaseTools>
& getInstace
(QString connection_name
);
static void setAllMultiThreaded (bool multithreaded_operations);
void setMultiThreaded (bool multithreaded_operations);
void connect ();
void close ();
void login ();
void logout ();
void suspend ();
bool isConnected ();
void setDbPort (int port);
signals:
void dbConnected
(QString connection_name
);
void dbClosed
(QString connection_name
);
void dbOperating
(QString connection_name
);
void dbReady
(QString connection_name
);
private slots:
void DatabaseThread_finished (DatabaseThread* thread);
void DatabaseObject_connected ();
void DatabaseObject_closed ();
};
#endif // DATABASETOOLS_H
#ifndef DATABASETOOLS_H
#define DATABASETOOLS_H
#include "DatabaseTools_global.h"
#include <QObject>
#include <QPointer>
#include <QStringList>
#include <QMap>
#include <QTimer>
#include "DatabaseHandle.h"
#include "DatabaseQueue.h"
#include "DatabaseThread.h"
#include "DatabaseQuery.h"
#include "DatabaseObject.h"
class DATABASETOOLSSHARED_EXPORT DatabaseTools : public QObject
{
static QMap<QString, QPointer<DatabaseTools> > PointersMap;
QTimer* UpdateTimer;
DatabaseHandle DbHandle;
DatabaseQueue DbQueue;
QString SessionUserName, SessionPassword;
bool IsDbEmpty;
QString DbVersion;
QString SupportedVersion;
QStringList UsersNamesList;
QString SessionId;
QString ConnectionName;
DatabaseTools (QString connection_name);
public:
static QPointer<DatabaseTools>& getInstace(QString connection_name);
static void setAllMultiThreaded (bool multithreaded_operations);
void setMultiThreaded (bool multithreaded_operations);
void connect ();
void close ();
void login ();
void logout ();
void suspend ();
bool isConnected ();
QString connectionName ();
void setDbAuthParams (QString host_name, QString user_name, QString password);
void setDbPort (int port);
void setSessionAuthParams (QString user_name, QString password);
signals:
void dbConnected (QString connection_name);
void dbClosed (QString connection_name);
void dbOperating (QString connection_name);
void dbReady (QString connection_name);
private slots:
void DatabaseThread_finished (DatabaseThread* thread);
void DatabaseObject_connected ();
void DatabaseObject_closed ();
};
#endif // DATABASETOOLS_H
To copy to clipboard, switch view to plain text mode
Application project file:
#-------------------------------------------------
#
# Project created by QtCreator 2012-07-30T20:05:45
#
#-------------------------------------------------
QT += core gui sql
TARGET = FitnessCenter-Application
TEMPLATE = app
LIBS += -L/home/zzz9/Projects/FitnessCenter/Build -lDatabaseTools
SOURCES += main.cpp\
MainWindow.cpp \
SetupWizard.cpp \
../Widgets/DatabaseStateWidget.cpp
HEADERS += MainWindow.h \
SetupWizard.h \
../Widgets/DatabaseStateWidget.h
FORMS += MainWindow.ui \
SetupWizard.ui \
../Widgets/DatabaseStateWidget.ui
RESOURCES += \
../Pixmaps/Pixmaps.qrc
OTHER_FILES += \
ÐапоминаниÑ.txt
DESTDIR = ../Build
CONFIG += link_prl
#-------------------------------------------------
#
# Project created by QtCreator 2012-07-30T20:05:45
#
#-------------------------------------------------
QT += core gui sql
TARGET = FitnessCenter-Application
TEMPLATE = app
LIBS += -L/home/zzz9/Projects/FitnessCenter/Build -lDatabaseTools
SOURCES += main.cpp\
MainWindow.cpp \
SetupWizard.cpp \
../Widgets/DatabaseStateWidget.cpp
HEADERS += MainWindow.h \
SetupWizard.h \
../Widgets/DatabaseStateWidget.h
FORMS += MainWindow.ui \
SetupWizard.ui \
../Widgets/DatabaseStateWidget.ui
RESOURCES += \
../Pixmaps/Pixmaps.qrc
OTHER_FILES += \
ÐапоминаниÑ.txt
DESTDIR = ../Build
CONFIG += link_prl
To copy to clipboard, switch view to plain text mode
Added after 19 minutes:
application and lib are in debug
Bookmarks