解决应用调用qt dll时,必须要将exe和qt依赖库放在一起的问题
This commit is contained in:
parent
146f0a1b7d
commit
9701d6f318
|
@ -81,6 +81,7 @@ win32 {
|
||||||
DESTDIR = ../../../../release/win/x86/Release/
|
DESTDIR = ../../../../release/win/x86/Release/
|
||||||
}
|
}
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = ../../../build/windows/Debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contains(QT_ARCH, x86_64){
|
contains(QT_ARCH, x86_64){
|
||||||
|
@ -89,6 +90,7 @@ win32 {
|
||||||
DESTDIR = ../../../../release/win/x64/Release/
|
DESTDIR = ../../../../release/win/x64/Release/
|
||||||
}
|
}
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = ../../../build/windows/x64/Debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,11 +42,9 @@ if (contains(DEFINES, OEM_HANWANG) || contains(DEFINES, OEM_LISICHENG) || contai
|
||||||
}
|
}
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
SOURCES += ../../../modules/saneui/dllmain.cpp
|
|
||||||
SOURCES += ../../../modules/saneui/qmfcapp.cpp
|
SOURCES += ../../../modules/saneui/qmfcapp.cpp
|
||||||
SOURCES += ../../../modules/saneui/qwinhost.cpp
|
SOURCES += ../../../modules/saneui/qwinhost.cpp
|
||||||
SOURCES += ../../../modules/saneui/qwinwidget.cpp
|
SOURCES += ../../../modules/saneui/qwinwidget.cpp
|
||||||
|
|
||||||
HEADERS += ../../../modules/saneui/qmfcapp.h
|
HEADERS += ../../../modules/saneui/qmfcapp.h
|
||||||
HEADERS += ../../../modules/saneui/qwinhost.h
|
HEADERS += ../../../modules/saneui/qwinhost.h
|
||||||
HEADERS += ../../../modules/saneui/qwinwidget.h
|
HEADERS += ../../../modules/saneui/qwinwidget.h
|
||||||
|
@ -117,6 +115,7 @@ win32 {
|
||||||
DESTDIR = ../../../../release/win/x86/Release/
|
DESTDIR = ../../../../release/win/x86/Release/
|
||||||
}
|
}
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = ../../../build/windows/Debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contains(QT_ARCH, x86_64){
|
contains(QT_ARCH, x86_64){
|
||||||
|
@ -125,6 +124,7 @@ win32 {
|
||||||
DESTDIR = ../../../../release/win/x64/Release/
|
DESTDIR = ../../../../release/win/x64/Release/
|
||||||
}
|
}
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = ../../../build/windows/x64/Debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,6 +266,7 @@ HEADERS += \
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
../../../modules/saneui/HGSaneUI.cpp \
|
../../../modules/saneui/HGSaneUI.cpp \
|
||||||
../../../modules/saneui/dialog_device_scan.cpp \
|
../../../modules/saneui/dialog_device_scan.cpp \
|
||||||
../../../modules/saneui/dialog_device_select.cpp
|
../../../modules/saneui/dialog_device_select.cpp \
|
||||||
|
../../../modules/saneui/dllmain.cpp
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#include "qmfcapp.h"
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "base/HGUtility.h"
|
||||||
|
|
||||||
|
#if defined (HG_CMP_MSC)
|
||||||
|
#include "qmfcapp.h"
|
||||||
#include "qwinwidget.h"
|
#include "qwinwidget.h"
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
HINSTANCE g_hInst = NULL;
|
HINSTANCE g_hInst = NULL;
|
||||||
bool g_ownApplication = FALSE;
|
bool g_ownApplication = FALSE;
|
||||||
|
@ -10,6 +14,26 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/)
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
g_hInst = hInstance;
|
g_hInst = hInstance;
|
||||||
|
|
||||||
|
HGChar moduleName[512];
|
||||||
|
HGBase_GetModuleName(DllMain, moduleName, 512);
|
||||||
|
HGChar modulePath[512];
|
||||||
|
HGBase_GetFilePath(moduleName, modulePath, 512);
|
||||||
|
|
||||||
|
char *env = getenv("QT_QPA_PLATFORM_PLUGIN_PATH");
|
||||||
|
if (NULL == env)
|
||||||
|
{
|
||||||
|
char newEnv[256];
|
||||||
|
sprintf(newEnv, "QT_QPA_PLATFORM_PLUGIN_PATH=%s", modulePath);
|
||||||
|
putenv(newEnv);
|
||||||
|
}
|
||||||
|
else if (NULL == strstr(env, modulePath))
|
||||||
|
{
|
||||||
|
char *newEnv = new char [strlen(env) + 256];
|
||||||
|
sprintf(newEnv, "QT_QPA_PLATFORM_PLUGIN_PATH=%s;%s", env, modulePath);
|
||||||
|
putenv(newEnv);
|
||||||
|
delete []newEnv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (dwReason == DLL_PROCESS_DETACH)
|
else if (dwReason == DLL_PROCESS_DETACH)
|
||||||
{
|
{
|
||||||
|
@ -20,3 +44,19 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
void __attribute__((constructor)) global_load(void);
|
||||||
|
void __attribute__((destructor)) global_unload(void);
|
||||||
|
|
||||||
|
void global_load(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void global_unload(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue