如何在Qt 5中創建DLL以在VBA中使用它?我有簡單的類:Qt5在VBA中的DLL錯誤運行時錯誤453
dllvba.h
#ifndef DLLVBA_H
#define DLLVBA_H
#include "dllvba_global.h"
class DLLVBASHARED_EXPORT DllVBA
{
public:
DllVBA();
int qsum();
};
#endif // DLLVBA_H
dllvba_global.h
#ifndef DLLVBA_GLOBAL_H
#define DLLVBA_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(DLLVBA_LIBRARY)
# define DLLVBASHARED_EXPORT Q_DECL_EXPORT
#else
# define DLLVBASHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // DLLVBA_GLOBAL_H
dllvba.cpp
#include "dllvba.h"
DllVBA::DllVBA()
{
}
int DllVBA::qsum()
{
return 2;
}
在VBA我使用代碼:
Declare Function DllVBA Lib "C:\QTProject\DllVBA\build-DllVBA-Desktop_Qt_5_7_0_MinGW_32bit-Debug\debug\DllVBA.dll"() As Object
Sub test()
Dim instance As Object
Set instance = DllVBA()
Debug.Print instance.qsum
End Sub
而且結果是錯誤:
Run-time error '453':
Can't find DLL entry DllVBA in C:\QTProject\DllVBA\build-DllVBA-Desktop_Qt_5_7_0_MinGW_32bit-Deb...
我不知道這個路邊的工作是否可以部署共享的dll並重試。只需Qt MinGW命令提示符並在現有目錄「windeployqt.exe DllVBA.dll」中鍵入DllVBA。並重新運行你的新應用程序。你能發佈輸出錯誤還是成功? – CMLDMR