Using loadlibrary with driverpackage
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
Im trying to use loadlibrary command on a driver package of TIA.
The package contain DLL,LIB files in addition to an header.
While loading library, Matlab yielded the following error:
Error using loadlibrary
Building x_thunk_pcwin64 failed. Compiler output is:
C:\ProgramData\MATLAB\SupportPackages\R2019b\3P.instrset\mingw_w64.instrset\bin\gcc -I"C:\Program Files\MATLAB\R2019b\extern\include" -fexceptions -fno-omit-frame-pointer -I"C:\Driver\example" -I"C:\Driver\example" "x_thunk_pcwin64.c"
-o "x_thunk_pcwin64.dll" -shared
In file included from x_thunk_pcwin64.c:27:0:
C:\Driver\example/LUCI_10.h:40:33: error: expected identifier or '(' before string constant
#define FEMTO_LUCI10_API extern "C" __declspec(dllimport)
^
C:\Driver\example/LUCI_10.h:46:1: note: in expansion of macro 'FEMTO_LUCI10_API'
FEMTO_LUCI10_API int EnumerateUsbDevices();
^~~~~~~~~~~~~~~~
C:\Driver\example/LUCI_10.h:40:33: error: expected identifier or '(' before string constant
#define FEMTO_LUCI10_API extern "C" __declspec(dllimport)
^
I read some where that there is a work around using extern "C" commad which should include {, although i tried adding it iny possible combinatiuon i didnt managed to make it work.
I'll appriciate your help/
0 Commenti
Risposte (1)
Thomas Chaigne
il 27 Nov 2019
Hi Amit,
I just bumped into the same issue today, and here is the fix I found.
Edit the header file (.h, you can actually open it with Matlab, back up the original one just in case), and delete the ' extern "C" ' part in the # define line. Then call loadlibrary with the new header.
According to https://stackoverflow.com/questions/2288293/windows-c-extern-declspecdllimport and https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c it might give issues with the function naming, check using libfunctions, I did not see any problem with my library.
Good luck, I'll let you know if I get something wrong at some point.
0 Commenti
Vedere anche
Categorie
Scopri di più su Call C from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!