Using LOADLIBRARY to load 'visa32.dll' and 'visa.h' in 64-bit Matlab R2017b
30 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
jy
il 17 Lug 2018
Modificato: Walter Roberson
il 12 Set 2018
With Matlab R2015b on 32-bit Windows 7, LOADLIBRARY was working fine:
library = 'C:\Windows\System32\visa32.dll';
headerFile = 'C:\Program Files\IVI Foundation\VISA\WinNT\include\visa_Matlab.h';
loadlibrary(library, headerFile, 'alias','visa32');
and I can use functions in 'visa32.dll', such as,
defaultRm = 0;
[err, defaultRm] = calllib('visa32', 'viOpenDefaultRM', defaultRm);
vi = 0;
InstrAddr = 'GPIB0::29::INSTR';
pInstrAddr = libpointer('int8Ptr', [int8( InstrAddr ) 0] );
[err, tempVar, vi] = calllib('visa32', 'viOpen', defaultRm, pInstrAddr, 0, 0, vi);
to open instrument's communication port...
But after I have upgraded to 64-bit Windows 7 and Matlab R2017b, LOADLIBRARY won't work any more, even I have use 62-bit versions of 'visa32.dll' and 'visa.h'. There are two problems:
(1) Firstly, Matlab complaints about not have the right compiler installed and can't even run LOADLIBRAY. Follow their online instruction to install the MinGW-w64 Compiler addon. This problem seems to have revolved.
(2) LOADLIBRAY seems to be able to run, but then it has the following error:
Failed to parse type '( fastcall )) viOpenDefaultRM ( ViPSession vi' original input '( fastcall )) viOpenDefaultRM ( ViPSession vi ' Found on line 217 of input from line 93 of file C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Include\visa.h Error parsing argument for function attribute function may be invalid. ...
I wonder if somebody could help please. Many thanks in advance!
0 Commenti
Risposta accettata
Siddharth Bhutiya
il 19 Lug 2018
It looks like this error could be related to one of the following two issues:
1) In 64-bit Windows, the VISA driver header files contain the "__fastcall" keyword in function signatures. "loadlibrary" is not able to deal with it and hence throws an error. This can be resolved by adding the following line at the top of the header file
#define __fastcall
You can refer to this MATLAB Answers post for more details:
2) Another possible cause of the error could be that the function definitions in the header file "visa.h" are written with ellipsis(“…”) to define variable number of inputs, such as:
ViStatus viPrintf ( ViSession vi , ViString writeFmt , ...);
This is misinterpreted by "loadlibrary" and hence it gives an error. A workaround for this is to explicitly define the number and type of arguments for the functions, by editing the prototype file. Details on how this is done can be found in the following MATLAB Answers post:
Hope this helps you resolve the issue.
0 Commenti
Più risposte (3)
grajcjan
il 10 Set 2018
Hi,I have used your file, but I still have a problem with fastcall
loadlibrary('C:\Windows\System32\visa64.dll', 'C:\Program Files\IVI Foundation\VISA\Win64\Include\visa_Matlab.h', 'alias','visa64')
Warning: Message from C preprocessor:
C:\Program Files\IVI Foundation\VISA\Win64\Include\visa_Matlab.h:102:0: warning:
"__fastcall" redefined
#define __fastcall
^
<built-in>: note: this is the location of the previous definition
> In loadlibrary
4 Commenti
Vedere anche
Categorie
Scopri di più su Instrument Control Toolbox Supported Hardware 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!