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
LFLAGS +=
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::INCLUDEPATH += /usr/local/include
macx:LIBS += -L/usr/local/lib -framework AVFoundation

@ -16,7 +16,11 @@
*/
#include "codec.h"
#include <iostream>
#ifdef Q_OS_WIN
#include <windows.h>
#else
#include <dlfcn.h>
#endif
#ifdef USE_FLITE
extern "C" {
@ -164,6 +168,7 @@ bool Codec::load_vocoder_plugin()
#else
QString voc = config_path + "/vocoder_plugin." + QSysInfo::kernelType() + "." + QSysInfo::currentCpuArchitecture();
#endif
#if !defined(Q_OS_WIN)
//QString voc = "/mnt/data/src/mbe_vocoder/vocoder_plugin.linux.x86_64.so";
void* a = dlopen(voc.toLocal8Bit(), RTLD_LAZY);
if (!a) {
@ -183,6 +188,26 @@ bool Codec::load_vocoder_plugin()
m_mbevocoder = create_a();
qDebug() << voc + " loaded";
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()

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

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

Loading…
Cancel
Save