Effacer les filtres
Effacer les filtres

Problem with loading dll

10 vues (au cours des 30 derniers jours)
Xiaofei Yu
Xiaofei Yu le 4 Juil 2020
Commenté : Xiaofei Yu le 13 Sep 2020
Dear Sir/Madam
We recentely use Matlab to control an instrument (sc5511a) in our lab.
We have both sc5511a.dll and sc5511a.h files
When loading library using the following line of the code
[notfound,warnings]=loadlibrary('sc5511a','sc5511a.h')
I got thousands lines of error as following:
'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\R2019b\toolbox\matlab\general\private\prototypes.pl line 912.
Type 'longlong__extension__' was not found. Defaulting to type error.
Found on line 1259 of input from line 478 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Type 'longlong__extension__' was not found. Defaulting to type error.
Found on line 1259 of input from line 478 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
found parens in LowPart ; LONG HighPart ; } ; struct { DWORD LowPart ; LONG HighPart ; } u ; LONGLONG QuadPart ; } LARGE_INTEGER
Match: DWORD LowPart ; LONG HighPart ;
Final string:LowPart ; LONG HighPart ; } ; struct u ; LONGLONG QuadPart ; } LARGE_INTEGER
Failed to parse type 'union _LARGE_INTEGER { __extension__ struct { DWORD LowPart ; LONG HighPart ; } ; struct { DWORD LowPart ; LONG HighPart ; } u ; LONGLONG QuadPart ; } LARGE_INTEGER' original input 'union _LARGE_INTEGER { __extension__ struct { DWORD LowPart ; LONG HighPart ; } ; struct { DWORD LowPart ; LONG HighPart ; } u ; LONGLONG QuadPart ; } LARGE_INTEGER'
Found on line 1290 of input from line 509 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr.
Found on line 1292 of input from line 511 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
found parens in LowPart ; DWORD HighPart ; } ; struct { DWORD LowPart ; DWORD HighPart ; } u ; ULONGLONG QuadPart ; } ULARGE_INTEGER
Match: DWORD LowPart ; DWORD HighPart ;
Final string:LowPart ; DWORD HighPart ; } ; struct u ; ULONGLONG QuadPart ; } ULARGE_INTEGER
Failed to parse type 'union _ULARGE_INTEGER { __extension__ struct { DWORD LowPart ; DWORD HighPart ; } ; struct { DWORD LowPart ; DWORD HighPart ; } u ; ULONGLONG QuadPart ; } ULARGE_INTEGER' original input 'union _ULARGE_INTEGER { __extension__ struct { DWORD LowPart ; DWORD HighPart ; } ; struct { DWORD LowPart ; DWORD HighPart ; } u ; ULONGLONG QuadPart ; } ULARGE_INTEGER'
Found on line 1308 of input from line 527 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Type 'ULARGE_INTEGERPtr' was not found. Defaulting to type voidPtr.
Found on line 1310 of input from line 529 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 16 ))) _M128A { ULONGLONG Low ; LONGLONG High ; } M128A' original input 'struct __attribute__ (( __aligned__ ( 16 ))) _M128A { ULONGLONG Low ; LONGLONG High ; } M128A '
Found on line 1649 of input from line 1355 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 16 ))) _M128A { ULONGLONG * PM128A' original input 'struct __attribute__ (( __aligned__ ( 16 ))) _M128A { ULONGLONG * PM128A'
Found on line 1649 of input from line 1355 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 16 ))) _XSAVE_FORMAT { WORD ControlWord ; WORD StatusWord ; BYTE TagWord ; BYTE Reserved1 ; WORD ErrorOpcode ; DWORD ErrorOffset ; WORD ErrorSelector ; WORD Reserved2 ; DWORD DataOffset ; WORD DataSelector ; WORD Reserved3 ; DWORD MxCsr ; DWORD MxCsr_Mask ; M128A *FloatRegisters; M128A *XmmRegisters; BYTE *Reserved4; } XSAVE_FORMAT' original input 'struct __attribute__ (( __aligned__ ( 16 ))) _XSAVE_FORMAT { WORD ControlWord ; WORD StatusWord ; BYTE TagWord ; BYTE Reserved1 ; WORD ErrorOpcode ; DWORD ErrorOffset ; WORD ErrorSelector ; WORD Reserved2 ; DWORD DataOffset ; WORD DataSelector ; WORD Reserved3 ; DWORD MxCsr ; DWORD MxCsr_Mask ; M128A FloatRegisters [ 8 ]; M128A XmmRegisters [ 16 ]; BYTE Reserved4 [ 96 ]; } XSAVE_FORMAT '
Found on line 1674 of input from line 1380 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 16 ))) _XSAVE_FORMAT { WORD * PXSAVE_FORMAT' original input 'struct __attribute__ (( __aligned__ ( 16 ))) _XSAVE_FORMAT { WORD * PXSAVE_FORMAT'
Found on line 1674 of input from line 1380 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 8 ))) _XSAVE_AREA_HEADER { DWORD64 Mask ; DWORD64 *Reserved; } XSAVE'
....
....
Type 'LARGE_INTEGER' was not found. Defaulting to type error.
Found on line 37342 of input from line 4062 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 16 ))) _MEMORY_BASIC_INFORMATION64 { ULONGLONG BaseAddress ; ULONGLONG AllocationBase ; DWORD AllocationProtect ; DWORD __alignment1 ; ULONGLONG RegionSize ; DWORD State ; DWORD Protect ; DWORD Type ; DWORD __alignment2 ; } MEMORY_BASIC_INFORMATION64' original input 'struct __attribute__ (( __aligned__ ( 16 ))) _MEMORY_BASIC_INFORMATION64 { ULONGLONG BaseAddress ; ULONGLONG AllocationBase ; DWORD AllocationProtect ; DWORD __alignment1 ; ULONGLONG RegionSize ; DWORD State ; DWORD Protect ; DWORD Type ; DWORD __alignment2 ; } MEMORY_BASIC_INFORMATION64 '
Found on line 37516 of input from line 4415 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'struct __attribute__ (( __aligned__ ( 16 ))) _MEMORY_BASIC_INFORMATION64 { ULONGLONG * PMEMORY_BASIC_INFORMATION64' original input 'struct __attribute__ (( __aligned__ ( 16 ))) _MEMORY_BASIC_INFORMATION64 { ULONGLONG * PMEMORY_BASIC_INFORMATION64'
Found on line 37516 of input from line 4415 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'union _FILE_SEGMENT_ELEMENT { PVOID64 Buffer ; ULONGLONG Alignment ; } FILE_SEGMENT_ELEMENT' original input 'union _FILE_SEGMENT_ELEMENT { PVOID64 Buffer ; ULONGLONG Alignment ; } FILE_SEGMENT_ELEMENT '
Found on line 37533 of input from line 4597 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Failed to parse type 'union _FILE_SEGMENT_ELEMENT { PVOID64 * PFILE_SEGMENT_ELEMENT' original input 'union _FILE_SEGMENT_ELEMENT { PVOID64 * PFILE_SEGMENT_ELEMENT'
Found on line 37533 of input from line 4597 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/winnt.h
Type 'LARGE_INTEGER' was not found. Defaulting to type error.
Found on line 37902 of input from line 5085 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w6'
....
.....
Found on line 82132 of input from line 575 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Function pointer types are unsupported in structures HRESULT ( * QueryInterface ) ( IPrintDialogCallback * .
Found on line 82141 of input from line 584 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Function pointer types are unsupported in structures HRESULT ( * HandleMessage ) ( IPrintDialogCallback * .
Found on line 82141 of input from line 584 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Type 'IPrintDialogServicesVtblPtr' was not found. Defaulting to type voidPtr.
Found on line 82145 of input from line 588 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Function pointer types are unsupported in structures HRESULT ( * QueryInterface ) ( IPrintDialogServices * .
Found on line 82154 of input from line 597 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Function pointer types are unsupported in structures HRESULT ( * GetCurrentDevMode ) ( IPrintDialogServices * .
Found on line 82154 of input from line 597 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Function pointer types are unsupported in structures HRESULT ( * GetCurrentPrinterName ) ( IPrintDialogServices * .
Found on line 82154 of input from line 597 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Function pointer types are unsupported in structures HRESULT ( * GetCurrentPortName ) ( IPrintDialogServices * .
Found on line 82154 of input from line 597 of file C:/ProgramData/MATLAB/SupportPackages/R2019b/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/commdlg.h
Type 'device_info_tPtr' was not found. Defaulting to type voidPtr.
Found on line 83089 of input from line 480 of file C:\\Users\\maurerlab\\Desktop\\SignalCoreMat\\sc5511a.h
Above, I only showed part of the errors as there are too many.
However, It seems that we have sucessfully loaded the libarary. E.g. When I type the following code:
libfunctions('sc5511a')
I got
Functions in library sc5511a:
sc5511a_close_device sc5511a_list_soft_trigger sc5511a_set_freq
sc5511a_get_alc_dac sc5511a_list_start_freq sc5511a_set_level
sc5511a_get_device_info sc5511a_list_step_freq sc5511a_set_output
sc5511a_get_device_status sc5511a_list_stop_freq sc5511a_set_reference_dac
sc5511a_get_rf_parameters sc5511a_open_device sc5511a_set_rf2_freq
sc5511a_get_signal_phase sc5511a_open_device_lv sc5511a_set_rf2_standby
sc5511a_get_temperature sc5511a_reg_read sc5511a_set_rf_mode
sc5511a_list_buffer_points sc5511a_reg_write sc5511a_set_signal_phase
sc5511a_list_buffer_read sc5511a_search_devices sc5511a_set_standby
sc5511a_list_buffer_transfer sc5511a_search_devices_lv sc5511a_set_synth_mode
sc5511a_list_buffer_write sc5511a_set_alc_dac sc5511a_store_default_state
sc5511a_list_cycle_count sc5511a_set_alc_mode sc5511a_synth_self_cal
sc5511a_list_dwell_time sc5511a_set_auto_level_disable usb_transfer
sc5511a_list_mode_config sc5511a_set_clock_reference
These are exactly the functions in the libarary.
I found some of the functions are working, but others are not, e.g.
a={'100023CC'}% store serial number of the device
calllib('sc5511a', 'sc5511a_search_devices',a) %%Search for device and return the number of device founded
The above code sucessfully return the number "1", which means it found 1 device with serial number '100023CC'
dev_handle = calllib('sc5511a', 'sc5511a_open_device','100023CC'); %%assign the handle
This line of the code sucessfuly opened our device (There is an LED light on the device showing it is sucessfully opened) and assign the libpointer to dev_handle.
Theoretically it means now, we can use this dev_handle to refer our device and apply other functions
However, when we use following function:
calllib('sc5511a', 'sc5511a_set_freq',dev_handle,1000000000); %%set up the frequency of the device to be 1000000000 hz
calllib('sc5511a', 'sc5511a_close_device',dev_handle);% close the device
Then matlab is crushed
It seems we can not use any functions related to dev_handle. They will all crush matlab.
Here I attatched .dll and .h file, could someone help us take a look? We tried various methods, e.g. we even tried to install different version of matlab, they seems not work
It would be nice if someone could tell us what's going there and how do we fix the problem, as we are in a hurry to set up an experiement

Réponse acceptée

John Powell
John Powell le 26 Août 2020
I have seen similar issues when trying to open a DLL in MATLAB. I recommend doing the following:
  1. type mex -setup and press enter. MATLAB will display the currently selected C compiler and available C compilers.
  2. If the current compiler is the MinGW compiler, and there is a Visual Studio option in blue text, click on that and MATLAB will switch to the Visual Studio compiler. If Visual Studio isn't listed, you will need to install a copy of Visual Studio. There's a free Community version (not tested by me) that may work. In my case, I happen to have Visual Studio 2015.
  3. If you have to install Visual Studio, exit and re-start MATLAB and re-run the command mex-setup. Then select the Visual Studio option that should now appear.
  4. Type mex -setup cpp and press enter. Again, select the Visual Studio option for the compiler.
  5. Try to load your DLL and communicate with your device again.
  1 commentaire
Xiaofei Yu
Xiaofei Yu le 13 Sep 2020
Thx for your effort. The company resent us a new dll file and it works

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by