Add dynamic library loading support for Windows

pull/2/head
Doug McLain 3 years ago
parent da5e464249
commit 7b3f248fab

@ -4,7 +4,11 @@ linux:QT += serialport
CONFIG += c++11 CONFIG += c++11
LFLAGS += LFLAGS +=
android:INCLUDEPATH += $$(HOME)/Android/android-build/include android:INCLUDEPATH += $$(HOME)/Android/android-build/include
LIBS += -limbe_vocoder -ldl LIBS += -limbe_vocoder
!win32:LIBS += -ldl
win32:QT += serialport
win32:INCLUDEPATH += /mnt/data/src/mxe/usr/include
win32:LIBS += -L/mnt/data/src/mxe/usr/lib64
macx:QT += serialport macx:QT += serialport
macx::INCLUDEPATH += /usr/local/include macx::INCLUDEPATH += /usr/local/include
macx:LIBS += -L/usr/local/lib -framework AVFoundation macx:LIBS += -L/usr/local/lib -framework AVFoundation

@ -16,7 +16,11 @@
*/ */
#include "codec.h" #include "codec.h"
#include <iostream> #include <iostream>
#ifdef Q_OS_WIN
#include <windows.h>
#else
#include <dlfcn.h> #include <dlfcn.h>
#endif
#ifdef USE_FLITE #ifdef USE_FLITE
extern "C" { extern "C" {
@ -164,6 +168,7 @@ bool Codec::load_vocoder_plugin()
#else #else
QString voc = config_path + "/vocoder_plugin." + QSysInfo::kernelType() + "." + QSysInfo::currentCpuArchitecture(); QString voc = config_path + "/vocoder_plugin." + QSysInfo::kernelType() + "." + QSysInfo::currentCpuArchitecture();
#endif #endif
#if !defined(Q_OS_WIN)
//QString voc = "/mnt/data/src/mbe_vocoder/vocoder_plugin.linux.x86_64.so"; //QString voc = "/mnt/data/src/mbe_vocoder/vocoder_plugin.linux.x86_64.so";
void* a = dlopen(voc.toLocal8Bit(), RTLD_LAZY); void* a = dlopen(voc.toLocal8Bit(), RTLD_LAZY);
if (!a) { if (!a) {
@ -183,6 +188,26 @@ bool Codec::load_vocoder_plugin()
m_mbevocoder = create_a(); m_mbevocoder = create_a();
qDebug() << voc + " loaded"; qDebug() << voc + " loaded";
return true; return true;
#else
HINSTANCE hinstvoclib;
hinstvoclib = LoadLibrary(reinterpret_cast<LPCWSTR>(voc.utf16()));
if (hinstvoclib != NULL) {
create_t* create_a = (create_t*)GetProcAddress(hinstvoclib, "create");
if (create_a != NULL) {
m_mbevocoder = create_a();
qDebug() << voc + " loaded";
return true;
}
else{
return false;
}
}
else{
return false;
}
#endif
} }
void Codec::deleteLater() void Codec::deleteLater()

@ -33,7 +33,6 @@
#include <QDir> #include <QDir>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h>
#include <iostream> #include <iostream>
DroidStar::DroidStar(QObject *parent) : DroidStar::DroidStar(QObject *parent) :
@ -222,7 +221,7 @@ void DroidStar::process_connect()
MicPermission::check_permission(); MicPermission::check_permission();
#endif #endif
//#include "build.h" #include "build.h"
if( (m_callsign.size() < 4) || if( (m_callsign.size() < 4) ||
(m_dmrid < 250000) || (m_dmrid < 250000) ||

@ -20,7 +20,6 @@
#include <QQuickStyle> #include <QQuickStyle>
#include <QIcon> #include <QIcon>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h>
#include "droidstar.h" #include "droidstar.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])

Loading…
Cancel
Save