Hello,

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.

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. 

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.

Problem: defcfun cannot find the function.

Here is the example code:

#include <visa.h>
#include <stdio.h>
#include <memory.h>
// This example opens a specific GPIB device, does an *idn query
// and prints the result.
int main(int argc, char* argv[])
{
ViSession rm = VI_NULL, vi = VI_NULL;
ViStatus status;
ViChar buffer[256];
ViUInt32 retCnt;
// Open a default session
status = viOpenDefaultRM(&rm);  <--------------- I want to access this function
if (status < VI_SUCCESS) goto error;
// Open the GPIB device at primary address 1, GPIB board 8
status = viOpen(rm, “GPIB8::1::INSTR”, VI_NULL, VI_NULL,
&vi);
if (status < VI_SUCCESS) goto error;

... etc

My cffi code is:
(cffi:defctype ViSession :int)
(cffi:defctype ViStatus :int)

(cffi:defcfun ("viOpenDefaultRM" vi-open-default-rm
                 :library tek-visa) ViStatus
  (rm ViSession))


And the library is defined thus:
(cffi:define-foreign-library tek-visa
  (:windows *VISA-lib*)) ;; *VISA-lib* contains path to the library

(cffi:use-foreign-library tek-visa)

defcfun gives warning that the foreign function does not exist.

Using `nm' I did find:
00000000 I __imp__viOpenDefaultRM@4
00000000 T _viOpenDefaultRM@4

I tried using these (and some variants), but got the same message.

Now, this is a Windows library, and clisp is on Cygwin.  Could that be the problem? Any other thoughts?

Thank you,

Mirko