Compiler error for external .dll (Thorlabs)

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 Kommentare

Anas Skalli
Anas Skalli am 3 Mär. 2023
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 am 27 Jun. 2023
Bumping this up again bcause I have the same issue.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ivan
Ivan am 20 Sep. 2023

0 Stimmen

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 Kommentar

James
James am 21 Sep. 2023
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Gefragt:

am 25 Mai 2020

Kommentiert:

am 21 Sep. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by