Using LOADLIBRARY to load 'visa32.dll' and 'visa.h' in 64-bit Matlab R2017b
조회 수: 20 (최근 30일)
이전 댓글 표시
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
채택된 답변
Siddharth Bhutiya
2018년 7월 19일
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
추가 답변 (3개)
grajcjan
2018년 9월 10일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Instrument Control Toolbox Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!