It's my first attempt to make a plugin. So...
My question is
What sould I do to build my project correctly with mingw and get plugin (I want to make it for both x64 and x32 windows and linux) workable?
I started from very beginning. Simpliest plugin with config form.
clock_alarm.h
Code:
#include "ts3_functions.h"
#ifndef CLOCK_ALARM_H_
#define CLOCK_ALARM_H_
#ifdef WIN32
#define PLUGINS_EXPORTDLL __declspec(dllexport)
#else
#define PLUGINS_EXPORTDLL __attribute__ ((visibility("default")))
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Required functions */
PLUGINS_EXPORTDLL const char* ts3plugin_name();
PLUGINS_EXPORTDLL const char* ts3plugin_version();
PLUGINS_EXPORTDLL int ts3plugin_apiVersion();
PLUGINS_EXPORTDLL const char* ts3plugin_author();
PLUGINS_EXPORTDLL const char* ts3plugin_description();
PLUGINS_EXPORTDLL void ts3plugin_setFunctionPointers(const struct TS3Functions funcs);
PLUGINS_EXPORTDLL int ts3plugin_init();
PLUGINS_EXPORTDLL void ts3plugin_shutdown();
PLUGINS_EXPORTDLL int ts3plugin_offersConfigure();
PLUGINS_EXPORTDLL void ts3plugin_configure(void* handle, void* qParentWidget);
PLUGINS_EXPORTDLL void ts3plugin_registerPluginID(const char* id);
#ifdef __cplusplus
}
#endif
#endif
clock_alarm.h
Code:
/**
All content of this file was copied from example source of pluginsdk
the only function I have modified:
*/
int ts3plugin_offersConfigure() {
printf("PLUGIN: offersConfigure\n");
return PLUGIN_OFFERS_CONFIGURE_QT_THREAD;
}
It was succesflly compilled to dll. TS3 recognized it as plugin. Welldone.
Then I added a form made by QtCreator.
cformclocksettings.h
Code:
#ifndef CFORMCLOCKSETTINGS_H
#define CFORMCLOCKSETTINGS_H
#include <QtGlobal>
#include <QDialog>
namespace Ui {
class CFormClockSettings;
}
class CFormClockSettings : public QDialog
{
Q_OBJECT
public:
explicit CFormClockSettings(QWidget *parent = 0);
~CFormClockSettings();
private:
Ui::CFormClockSettings *ui;
};
#endif // CFORMCLOCKSETTINGS_H
cformclocksettings.cpp
Code:
#include "cformclocksettings.h"
#include "ui_cformclocksettings.h"
CFormClockSettings::CFormClockSettings(QWidget *parent) :
QDialog(parent),
ui(new Ui::CFormClockSettings)
{
ui->setupUi(this);
}
CFormClockSettings::~CFormClockSettings()
{
delete ui;
}
cformclocksettings.ui is much longer so lets leave it out. It's empty dialog form with two buttons: "Ok" and "Cancel" and one label as "Hello world!".
din.pro
Code:
QT += \
widgets
#INCLUDEPATH += ./ts3_include
TARGET = din
TEMPLATE = lib
CONFIG += qt dll shared plugin
DEFINES += DIN_LIBRARY
SOURCES += \
clock_alarm.cpp \
cformclocksettings.cpp
HEADERS +=\
clock_alarm.h \
cformclocksettings.h
unix {
target.path = /usr/lib
INSTALLS += target
}
FORMS += \
cformclocksettings.ui
And I've got trouble here...
It successfully compiled to dll. But TS3 doesn't want to work with it any more.
From TS log files I've got that:
Code:
Failed to load plugin: C:\Program Files (x86)\TeamSpeak 3 Client\plugins\din.dll
LoadLibrary error: 193
I've tried to plug it to both versions of TS (x64, x32), nothing changed.
That form wasn't even called, and plugin doesn't work already!
Then I installed Visual Studio 2013 to get one more compiler.
Hm...
It compiled version suitable for TS3_x64. Ok, my code is correct... maybe...
My stuffs:
windows 8.1
mingw from http://www.mingw.org/ current mingw32-gcc vesion 4.8.1-4
qt from http://www.qt.io/ru/download/
it's QtCreator version 3.3.2
and Qt version 5.4.1
Visual Studio 2013 (to get one more compiler)
TS3 version 3.0.16 x32 & x64 (Qt 5.2.1)
I'm noob in Qt and plugin development. Is there any magic in it?