Error with loadlibrary to upload DLL file

9 views (last 30 days)
Alisha Menon
Alisha Menon on 7 Jun 2017
Commented: Alisha Menon on 14 Jun 2017
I am currently trying to use loadlibrary to upload a dll into MATLAB and have the following error:
loadlibrary('SLAB_USB_SPI','SLAB_USB_SPI.h')
Warning: Warnings messages were produced while parsing. Check the functions you intend to use for
correctness. Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********
Type 'char_Null_terminated_Ptr' was not found. Defaulting to type voidPtr.
Found on line 53 of input from line 52 of file C:\\SiliconLabs\\MCU\\CP2130_SDK\\Software\\Library\\SLAB_USB_SPI.h
Type 'char_Null_terminated_Ptr' was not found. Defaulting to type voidPtr.
Found on line 54 of input from line 53 of file C:\\SiliconLabs\\MCU\\CP2130_SDK\\Software\\Library\\SLAB_USB_SPI.h
Type 'int_Out_LPGUID' was not found. Defaulting to type error.
Found on line 418 of input from line 417 of file C:\\SiliconLabs\\MCU\\CP2130_SDK\\Software\\Library\\SLAB_USB_SPI.h
Type 'LPGUID' was not found. Defaulting to type error.
Found on line 421 of input from line 420 of file C:\\SiliconLabs\\MCU\\CP2130_SDK\\Software\\Library\\SLAB_USB_SPI.h
*********
Error using loadlibrary
Building SLAB_USB_SPI_thunk_pcwin64 failed. Compiler output is:
cl -I"C:\Program Files\MATLAB\R2017a\extern\include" /W3 /nologo -I"C:\Program
Files\MATLAB\R2017a\extern\include" -I"C:\Program Files\MATLAB\R2017a\simulink\include"
/DTARGET_API_VERSION=700 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0
-I"C:\Users\subnets\Documents\MATLAB" -I"C:\SiliconLabs\MCU\CP2130_SDK\Software\Library"
"SLAB_USB_SPI_thunk_pcwin64.c" -LD -Fe"SLAB_USB_SPI_thunk_pcwin64.dll"
SLAB_USB_SPI_thunk_pcwin64.c
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(52) : error C2054: expected '(' to
follow '_Null_terminated_'
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(52) : error C2085: 'LPSTR' : not in
formal parameter list
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(53) : error C2628: '_Null_terminated_'
followed by 'char' is illegal (did you forget a ';'?)
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(53) : error C2085: 'LPCSTR' : not in
formal parameter list
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(73) : error C2085: 'CP213x_DEVICE' :
not in formal parameter list
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(74) : error C2085: 'USB_SPI_STATUS' :
not in formal parameter list
C:\SiliconLabs\MCU\CP2130_SDK\Software\Library\SLAB_USB_SPI.h(146) : error C2085: 'inline' : not in
formal parameter list
Does anyone have any suggestions about how to fix this? I am not sure what could be causing this.
  4 Comments
Walter Roberson
Walter Roberson on 7 Jun 2017
It has to do with Microsoft's Removable Storage Manager Protocol, which in turn relates to using USB devices.
Alisha Menon
Alisha Menon on 14 Jun 2017
I managed to get the dll loaded, the issue was that I was using 64-bit MATLAB. The 64-bit version of MATLAB generates a thunk.c file which seems to be the main issue with using a C++ header file (more information on that can be found on this blog post: https://ofekshilon.com/2016/07/15/on-matlabs-loadlibrary-proto-file-and-pcwin64-thunk/#comment-9669).
I had to download 32-bit MATLAB 2015b (which I believe is the last version of MATLAB to have a 32-bit version) and the loadlibrary function worked with a few warnings but no errors. It seems to be running well so far. Hopefully this helps anyone else that runs into a similar issue!

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!