Problem with loading .dll

7 Ansichten (letzte 30 Tage)
Yimai Peng
Yimai Peng am 7 Aug. 2016
Beantwortet: spinecho am 16 Nov. 2017
Hi,
I recently encountered a problem when I tried to load external .dll file in Matlab.
>>loadlibrary('okFrontPanel','okFrontPanelDLL.h')
Error using loadlibrary
Building okFrontPanel_thunk_pcwin64 failed. Compiler output is:
C:\MATLAB\SupportPackages\R2015b\MW_MinGW_4_9\\bin\gcc -I"D:\Matlab\extern\include" -fexceptions -fno-omit-frame-pointer
-I"D:\Matlab\My Project\win64" -I"D:\Matlab\My Project\win64" "okFrontPanel_thunk_pcwin64.c" -o "okFrontPanel_thunk_pcwin64.dll"
-shared
In file included from okFrontPanel_thunk_pcwin64.c:27:0:
D:\Matlab\My Project\win64/okFrontPanelDLL.h:401:94: error: unknown type name 'okEFPGAConfigurationMethod'
okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetFPGAResetProfile(okFrontPanel_HANDLE hnd, okEFPGAConfigurationMethod method,
okTFPGAResetProfile *profile);
^
D:\Matlab\My Project\win64/okFrontPanelDLL.h:402:94: error: unknown type name 'okEFPGAConfigurationMethod'
okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetFPGAResetProfile(okFrontPanel_HANDLE hnd, okEFPGAConfigurationMethod method,
const okTFPGAResetProfile *profile);
^
okFrontPanel_thunk_pcwin64.c: In function 'ok_ErrorCodeulongokEFPGAConfigurationMethodvoidPtrThunk':
okFrontPanel_thunk_pcwin64.c:435:2: error: unknown type name 'okEFPGAConfigurationMethod'
okEFPGAConfigurationMethod p1;
^
okFrontPanel_thunk_pcwin64.c:439:7: error: 'okEFPGAConfigurationMethod' undeclared (first use in this function)
p1=*(okEFPGAConfigurationMethod const *)callstack;
^
okFrontPanel_thunk_pcwin64.c:439:7: note: each undeclared identifier is reported only once for each function it appears in
okFrontPanel_thunk_pcwin64.c:439:34: error: expected ')' before 'const'
p1=*(okEFPGAConfigurationMethod const *)callstack;
^
okFrontPanel_thunk_pcwin64.c:439:42: error: expected ';' before 'callstack'
p1=*(okEFPGAConfigurationMethod const *)callstack;
^
okFrontPanel_thunk_pcwin64.c:443:44: error: expected declaration specifiers or '...' before 'okEFPGAConfigurationMethod'
return ((ok_ErrorCode (*)(unsigned long , okEFPGAConfigurationMethod , void * ))fcn)(p0 , p1 , p2);
^
okFrontPanel_thunk_pcwin64.c:443:82: error: expected ')' before 'fcn'
return ((ok_ErrorCode (*)(unsigned long , okEFPGAConfigurationMethod , void * ))fcn)(p0 , p1 , p2);
It seems something wrong with "okFrontPanel_thunk_pcwin64", cause I am using Matlab 64-bit version and trying to load a 64-bit library. Could anyone give information about this problem? Thanks a lot.

Antworten (2)

Image Analyst
Image Analyst am 7 Aug. 2016
Search the forum for "thunk" for prior discussions.
  1 Kommentar
Yimai Peng
Yimai Peng am 8 Aug. 2016
Of course I did this, but still find no answer for this. Now I am working with the 32-bit Matlab. Thanks for your reply.

Melden Sie sich an, um zu kommentieren.


spinecho
spinecho am 16 Nov. 2017
(α) In Matlab run
loadlibrary('okFrontPanel', 'okFrontPanelDLL.h', 'notempdir');
This disables the temp folder thus both the matlab-protofile and the thunk.c file will stay in your working folder. Generates lots of errors too but we can ignore them. So you now have in your working folder the following two files:
okFrontPanel_proto.m
okFrontPanel_thunk_pcwin64.c
(β) Rename okFrontPanel_thunk_pcwin64.c to okFrontPanel_thunk_pcwin64.cpp
(γ) Copy tmwtypes.h from
C:\Program Files\MATLAB\R2014a\extern\include
into your working folder or include path to tmwtypes.h: Additional Include Directories
(δ) Open okFrontPanel_thunk_pcwin64.cpp and change
#include <tmwtypes.h>
to
#include "tmwtypes.h"
Also add
int main(){
return 0;
}
(ε) In the command prompt (in my case the Windows SDK Command Prompt) run
cl /EHsc /LD okFrontPanel_thunk_pcwin64.cpp
to create the dll
okFrontPanel_thunk_pcwin64.dll
(στ) In Matlab -> Set Path -> add
C:\Program Files\Opal Kelly\FrontPanelUSB\API-64
(ζ) In Matlab run
loadlibrary('okFrontPanel',@okFrontPanel_proto)
If you interested in the technical details in regard to the thunk and proto files have a look here: On Matlab’s loadlibrary, proto file and pcwin64 thunk

Kategorien

Mehr zu MATLAB Compiler SDK finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by