#ifndef DLL_H#define DLL_H#include <QString>#include "DLL__global.h"extern "C" { QString oddUpper(const QString& str);}#endif // DLL_H
#include "dll.h"QString oddUpper(const QString &str){ QString strTemp; for(int i = 0; i < str.length(); ++i){ strTemp += (i % 2) ? str.at(i) : str.at(i).toUpper(); } return strTemp;}
int main(int argc, char *argv[]){ QApplication a(argc, argv); QLabel lbl("this is example text"); QLibrary lib("DLL_"); typedef QString (*Fct)(const QString&); Fct fct = (Fct)(lib.resolve("oddUpper")); if(fct){ lbl.setText(fct(lbl.text())); } lbl.show(); return a.exec();}
#ifdef MYCLASS_LIB# define MYCLASS_EXPORT Q_DECL_EXPORT#else# define MYCLASS_EXPORT Q_DECL_IMPORT#endifclass MYCLASS_EXPORT QtAddonSB{
#ifndef DLL_H#define DLL_H#include <QString>#include "DLL__global.h" //заголовочный файл с дефайнамиMYCLASS_EXPORT QString oddUpper(const QString& str);#endif // DLL_H
#include <QtGui> #if defined TEST #define TEST_COMMON_DLLSPEC Q_DECL_EXPORT #else #define TEST_COMMON_DLLSPEC Q_DECL_IMPORT #endif extern "C" TEST_COMMON_DLLSPEC QWidget* createWidget1();