Тема: error: undefined reference to `vtable for ...
Зробив DLL за допомогою QT + MinGW
pro file
#-------------------------------------------------
#
# Project created by QtCreator 2018-04-01T04:51:46
#
#-------------------------------------------------
QT -= gui
TARGET = kuins_method
TEMPLATE = lib
DEFINES += KUAINRULE_EXPORTS
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
../kuins_method_file/abstractnormalform.cpp \
../kuins_method_file/abstractobject.cpp \
../kuins_method_file/constituent.cpp \
../kuins_method_file/expression.cpp \
../kuins_method_file/initkuainrule.cpp \
../kuins_method_file/kuainrule.cpp \
../kuins_method_file/normalform.cpp \
../kuins_method_file/perfectnormalform.cpp \
../kuins_method_file/shortnormalform.cpp
HEADERS += \
../kuins_method_file/abstractnormalform.h \
../kuins_method_file/abstractobject.h \
../kuins_method_file/constituent.h \
../kuins_method_file/defines.h \
../kuins_method_file/expression.h \
../kuins_method_file/global.h \
../kuins_method_file/initkuainrule.h \
../kuins_method_file/kuainrule.h \
../kuins_method_file/normalform.h \
../kuins_method_file/perfectnormalform.h \
../kuins_method_file/shortnormalform.h
unix {
target.path = /usr/lib
INSTALLS += target
}
global file
#ifndef GLOBAL_H
#define GLOBAL_H
#ifdef _MSC_VER
#ifdef KUAINRULE_EXPORTS
#define KUAINRULE_API __declspec(dllexport)
#else
#define KUAINRULE_API __declspec(dllimport)
#endif
#elif __MINGW32__
#include <QtCore/qglobal.h>
#ifdef KUAINRULE_EXPORTS
# define KUAINRULE_API Q_DECL_EXPORT
#else
# define KUAINRULE_API Q_DECL_IMPORT
#endif
#else
#error MSVC or Qt + MinGW compiler required.
#endif
#endif // GLOBAL_H
Біля кожної імпортованої функції добавив макрос
Ось приклад:
namespace nsKuainRule {
class NormalForm : public AbstractNormalForm, public AbstractObject
{
std::vector <Expression> _expressionNFs;
public:
/**** CONSTRUCTOR & DESTRUCTOR ****/
KUAINRULE_API NormalForm();
KUAINRULE_API ~NormalForm();
/**** OVERRIDE FUNCTIONS ****/
/*!
* \brief Get all expressions from the NF class
* \return Vector of \a Expression objects
*/
KUAINRULE_API std::vector<Expression> &getAllExpr() override;
KUAINRULE_API std::string print() const override;
};
}
скомпілював як дебаг так і резі, без помилок
Підключаю
pro file
TEMPLATE = app
CONFIG += console c++14
CONFIG -= app_bundle
CONFIG += qt
TARGET = kuins_method
TEMPLATE = lib
DEFINES += KUAINRULE_EXPORTS
DEFINES += QT_DEPRECATED_WARNINGS
QT += core
QT -= gui
SOURCES += main.cpp
HEADERS += \
abstractnormalform.h \
abstractobject.h \
constituent.h \
defines.h \
expression.h \
global.h \
initkuainrule.h \
kuainrule.h \
normalform.h \
perfectnormalform.h \
shortnormalform.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/./ -lkuins_metho
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/./ -lkuins_method
INCLUDEPATH += $$PWD/.
DEPENDPATH += $$PWD/.
при компіляції помилка error: undefined reference to `vtable for ...
*.а, *.dll, *.h - скопіював до кореневої директорії
Що зробити для того щоб позбутися помилки ?