using the creator gui:
new project -> c++ library -> Type= Shared library
This gives me:
pro file
QT -= core gui
TARGET = helloworld_dll
TEMPLATE = lib
DEFINES += HELLOWORLD_DLL_LIBRARY
SOURCES += helloworld_dll.cpp
HEADERS += helloworld_dll.h\
helloworld_dll_global.h
QT -= core gui
TARGET = helloworld_dll
TEMPLATE = lib
DEFINES += HELLOWORLD_DLL_LIBRARY
SOURCES += helloworld_dll.cpp
HEADERS += helloworld_dll.h\
helloworld_dll_global.h
To copy to clipboard, switch view to plain text mode
header
#ifndef HELLOWORLD_DLL_H
#define HELLOWORLD_DLL_H
#include "helloworld_dll_global.h"
class HELLOWORLD_DLLSHARED_EXPORT Helloworld_dll {
public:
Helloworld_dll();
void print();
};
#endif // HELLOWORLD_DLL_H
#ifndef HELLOWORLD_DLL_H
#define HELLOWORLD_DLL_H
#include "helloworld_dll_global.h"
class HELLOWORLD_DLLSHARED_EXPORT Helloworld_dll {
public:
Helloworld_dll();
void print();
};
#endif // HELLOWORLD_DLL_H
To copy to clipboard, switch view to plain text mode
source
#include "helloworld_dll.h"
#include <iostream>
Helloworld_dll::Helloworld_dll()
{
}
void Helloworld_dll::print()
{
std::cout << "hi from dll\n";
}
#include "helloworld_dll.h"
#include <iostream>
Helloworld_dll::Helloworld_dll()
{
}
void Helloworld_dll::print()
{
std::cout << "hi from dll\n";
}
To copy to clipboard, switch view to plain text mode
dll defines
#ifndef HELLOWORLD_DLL_GLOBAL_H
#define HELLOWORLD_DLL_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(HELLOWORLD_DLL_LIBRARY)
# define HELLOWORLD_DLLSHARED_EXPORT Q_DECL_EXPORT
#else
# define HELLOWORLD_DLLSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // HELLOWORLD_DLL_GLOBAL_H
#ifndef HELLOWORLD_DLL_GLOBAL_H
#define HELLOWORLD_DLL_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(HELLOWORLD_DLL_LIBRARY)
# define HELLOWORLD_DLLSHARED_EXPORT Q_DECL_EXPORT
#else
# define HELLOWORLD_DLLSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // HELLOWORLD_DLL_GLOBAL_H
To copy to clipboard, switch view to plain text mode
Bookmarks