<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello,<br><br>Disclaimer: I am a newbie at all things C, including CFFI.  Thus what I am trying to do may not be possible.  The following is on Windows 7.  I use clisp on cygwin.<br>
</div><div><br></div>I am trying to link to a VISA library (VISA is used to control data acquisition instruments), visa32.lib compiled for Windows.  The library is shipped with Tektronix software.  <br><br>The manual gives examples of using the library using C++, and I am trying to follow the first example.  To me it looked pretty much like C - no objects, templates at least.<br>
<br>Problem: defcfun cannot find the function.<br><br></div>Here is the example code:<br><br>#include <visa.h><br>#include <stdio.h><br>#include <memory.h><br>// This example opens a specific GPIB device, does an *idn query<br>
// and prints the result.<br>int main(int argc, char* argv[])<br>{<br>ViSession rm = VI_NULL, vi = VI_NULL;<br>ViStatus status;<br>ViChar buffer[256];<br>ViUInt32 retCnt;<br>// Open a default session<br>status = viOpenDefaultRM(&rm);  <--------------- I want to access this function<br>
if (status < VI_SUCCESS) goto error;<br>// Open the GPIB device at primary address 1, GPIB board 8<br>status = viOpen(rm, “GPIB8::1::INSTR”, VI_NULL, VI_NULL,<br>&vi);<br>if (status < VI_SUCCESS) goto error;<br>
<br></div>... etc<br><br></div>My cffi code is:<br>(cffi:defctype ViSession :int)<br>(cffi:defctype ViStatus :int)<br><br>(cffi:defcfun ("viOpenDefaultRM" vi-open-default-rm<br>                 :library tek-visa) ViStatus<br>
  (rm ViSession))<br><br><br></div>And the library is defined thus:<br>(cffi:define-foreign-library tek-visa<br>  (:windows *VISA-lib*)) ;; *VISA-lib* contains path to the library<br><br>(cffi:use-foreign-library tek-visa)<br>
<br></div>defcfun gives warning that the foreign function does not exist.<br><br></div>Using `nm' I did find:<br>00000000 I __imp__viOpenDefaultRM@4<br>00000000 T _viOpenDefaultRM@4<br><br></div>I tried using these (and some variants), but got the same message.<br>
<br></div>Now, this is a Windows library, and clisp is on Cygwin.  Could that be the problem? Any other thoughts?<br><br>Thank you,<br><br>Mirko<br></div>