Hi All,
I have been trying to create a shared library using guidelines from the article https://doc.qt.io/qt-5/sharedlibrary.html :
Qt .pro :profile1.pro
QT += qml quick core
TARGET = profile1
TEMPLATE = lib
DEFINES += PROFILE1_LIBRARY
# 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 += \
profile1.cpp
HEADERS += \
profile1.h \
profile1_global.h
unix {
target.path = /usr/lib
INSTALLS += target
}
QT += qml quick core
TARGET = profile1
TEMPLATE = lib
DEFINES += PROFILE1_LIBRARY
# 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 += \
profile1.cpp
HEADERS += \
profile1.h \
profile1_global.h
unix {
target.path = /usr/lib
INSTALLS += target
}
To copy to clipboard, switch view to plain text mode
Main header :profile1_global.h
#ifndef PROFILE1_GLOBAL_H
#define PROFILE1_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(PROFILE1_LIBRARY)
# define PROFILE1SHARED_EXPORT Q_DECL_EXPORT
#else
# define PROFILE1SHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // PROFILE1_GLOBAL_H
#ifndef PROFILE1_GLOBAL_H
#define PROFILE1_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(PROFILE1_LIBRARY)
# define PROFILE1SHARED_EXPORT Q_DECL_EXPORT
#else
# define PROFILE1SHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // PROFILE1_GLOBAL_H
To copy to clipboard, switch view to plain text mode
Header :profile1.h
#ifndef PROFILE1_H
#define PROFILE1_H
#include "profile1_global.h"
class PROFILE1SHARED_EXPORT Profile1
{
public:
Profile1();
void func1();
};
#endif // PROFILE1_H
#ifndef PROFILE1_H
#define PROFILE1_H
#include "profile1_global.h"
class PROFILE1SHARED_EXPORT Profile1
{
public:
Profile1();
void func1();
};
#endif // PROFILE1_H
To copy to clipboard, switch view to plain text mode
Code : profile1.cpp
#include "profile1.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
Profile1::Profile1()
{
}
#include "profile1.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
Profile1::Profile1()
{
}
To copy to clipboard, switch view to plain text mode
I keep getting an error for class declaration : class PROFILE1SHARED_EXPORT Profile1 -" variable has incomplete type 'class Q_DECL_EXPORT' "
Thank you in advance for your help.
Bookmarks