Compiler error for external .dll (Thorlabs)

조회 수: 23 (최근 30일)
UltraFastPhysist
UltraFastPhysist 2020년 5월 25일
댓글: James 2023년 9월 21일
Hi all,
I want to use an USB-powermeter from Thorlabs (https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=9005) with Matlab. Unfortunately, it is not so straightforward as I hoped it is. I tried to load the dlls but the compiler gives me errors listed below. I have not much experience with dlls so I am not exactly sure how I can tackle this problem. Somehow it seems to me that my compiler has not the right version or isn´t "suited" here. In principal though, it should somehow work when there are examples for Labview/Python.
Any hint would be appreciated.
Thanks!
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/struct([^;,{(]*){ <-- HERE (.*?)\}([^;])*;/ at C:\Program Files\MATLAB\R2019a\toolbox\matlab\general\private\prototypes.pl line 912.
Failed to parse type '( __fastcall__ )) TLPM_close ( ViSession vi' original input '( __fastcall__ )) TLPM_close ( ViSession vi '
Found on line 111 of input from line 213 of file E:\\Matlab_scripts\\ThorlabsUSBPowermeter\\TLPM.h
Error parsing argument for function __attribute__ function may be invalid.
Failed to parse type '( __fastcall__ )) TLPM_presetRegister ( ViSession vi' original input '( __fastcall__ )) TLPM_presetRegister ( ViSession vi '
Found on line 125 of input from line 234 of file E:\\Matlab_scripts\\ThorlabsUSBPowermeter\\TLPM.h
Error parsing argument for function __attribute__ function may be invalid.
Failed to parse type '( __fastcall__ )) TLPM_startDarkAdjust ( ViSession vi' original input '( __fastcall__ )) TLPM_startDarkAdjust ( ViSession vi '
Found on line 165 of input from line 505 of file E:\\Matlab_scripts\\ThorlabsUSBPowermeter\\TLPM.h
Error parsing argument for function __attribute__ function may be invalid.
Failed to parse type '( __fastcall__ )) TLPM_cancelDarkAdjust ( ViSession vi' original input '( __fastcall__ )) TLPM_cancelDarkAdjust ( ViSession vi '
Found on line 166 of input from line 506 of file E:\\Matlab_scripts\\ThorlabsUSBPowermeter\\TLPM.h
Error parsing argument for function __attribute__ function may be invalid.
Failed to parse type '( __fastcall__ )) TLPM_reinitSensor ( ViSession vi' original input '( __fastcall__ )) TLPM_reinitSensor ( ViSession vi '
Found on line 231 of input from line 684 of file E:\\Matlab_scripts\\ThorlabsUSBPowermeter\\TLPM.h
Error parsing argument for function __attribute__ function may be invalid.
Failed to parse type '( __fastcall__ )) TLPM_reset ( ViSession vi' original input '( __fastcall__ )) TLPM_reset ( ViSession vi '
Found on line 306 of input from line 877 of file E:\\Matlab_scripts\\ThorlabsUSBPowermeter\\TLPM.h
Error parsing argument for function __attribute__ function may be invalid.
Warning no reference to header 'visa' added with addheader was found in source.
*********
Error using loadlibrary
Building TLPM_64_thunk_pcwin64 failed. Compiler output is:
C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
-I"E:\Matlab_scripts\ThorlabsUSBPowermeter" -I"C:\Program Files\MATLAB\R2019a\extern\include" -fexceptions
-fno-omit-frame-pointer -I"E:\Matlab_scripts\ThorlabsUSBPowermeter"
-I"E:\Matlab_scripts\ThorlabsUSBPowermeter" "TLPM_64_thunk_pcwin64.c" -o "TLPM_64_thunk_pcwin64.dll" -shared
TLPM_64_thunk_pcwin64.c:33:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token
EXPORT_EXTERN_C long long(__fastcall__))TLPM_close(ViSessionviThunk(void fcn(),const char *callstack,int
stacksize)
^
TLPM_64_thunk_pcwin64.c:42:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token
EXPORT_EXTERN_C long long(__fastcall__))TLPM_presetRegister(ViSessionviThunk(void fcn(),const char
*callstack,int stacksize)
^
TLPM_64_thunk_pcwin64.c:51:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token
EXPORT_EXTERN_C long long(__fastcall__))TLPM_startDarkAdjust(ViSessionviThunk(void fcn(),const char
*callstack,int stacksize)
^
TLPM_64_thunk_pcwin64.c:60:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token
EXPORT_EXTERN_C long long(__fastcall__))TLPM_cancelDarkAdjust(ViSessionviThunk(void fcn(),const char
*callstack,int stacksize)
^
TLPM_64_thunk_pcwin64.c:69:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token
EXPORT_EXTERN_C long long(__fastcall__))TLPM_reinitSensor(ViSessionviThunk(void fcn(),const char
*callstack,int stacksize)
^
TLPM_64_thunk_pcwin64.c:78:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token
EXPORT_EXTERN_C long long(__fastcall__))TLPM_reset(ViSessionviThunk(void fcn(),const char *callstack,int
stacksize)
  댓글 수: 2
Anas Skalli
Anas Skalli 2023년 3월 3일
Hello,
I have the same probelm trying to load "TLPMX_64.dll". Did you manage to fix this issue ?
line of code /
[notfound, warnings] = loadlibrary('TLPMX_64.dll', 'TLPMX.h','includepath', 'C:\Program Files\IVI Foundation\VISA\Win64\Include\');
Thanks!
James
James 2023년 6월 27일
Bumping this up again bcause I have the same issue.

댓글을 달려면 로그인하십시오.

답변 (1개)

Ivan
Ivan 2023년 9월 20일
I had the same issue, and asked technical support about it. The full story is here https://www.mathworks.com/matlabcentral/answers/2019396-strange-behaviour-of-loadlibrary-in-matlab-2023a
The workaround in my case was adding the line "#define __fastcall" to the libraryr .h file
Regards,
Ivan
  댓글 수: 1
James
James 2023년 9월 21일
I will try that thank you. Currently we are using the VISA interface but if we want to also use the Thorlabs software then we have to use the switcher application which needs an IT ticket everytime because we don't have admin rights.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by