Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

linking gpib-32.obj on windows

Dear All,

I'm in the process of writing a piece of Java code to drive a GPIB interface. ini order to do that, I use swig (http://www.swig.org ) to generate the JNI wrapper around the drivers. This application has to run on linux and windows, so I use libgpib for linux and the NI drivers (namely ni488.h and gpib-32.obj) for windows (both drivers have the same interface). This works well on Linux, but I can't get it to work on windows. I tried with two compilers (minGW and VS C++ 2005), and I have the following errors during the linking stage (with VS, sorry the error messages are in french, but they simply mean "external symbol not found"):

link linux-gpib_wrap.obj "c:\program files\national instruments\NI-488.2\languages\microsoft C\gpib-32.obj" "c:\program files\Microsoft Platform SDK for Windows server 2003 R2\lib\uuid.lib" "c:\program files\java\jdk1.6.0_04/lib/jvm.lib"

linux-gpib_wrap.obj : error LNK2019: symbole externe non résolu _AllSPoll référe
ncé dans la fonction _Java_linuxgpibJNI_AllSPoll@28
linux-gpib_wrap.obj : error LNK2019: symbole externe non résolu _AllSpoll référe
ncé dans la fonction _Java_linuxgpibJNI_AllSpoll@28
linux-gpib_wrap.obj : error LNK2019: symbole externe non résolu _DevClear référe
ncé dans la fonction _Java_linuxgpibJNI_DevClear@20
[..]
linux-gpib_wrap.obj : error LNK2019: symbole externe non résolu _ibwrtf référenc
é dans la fonction _Java_linuxgpibJNI_ibwrtf@16
linux-gpib_wrap.obj : error LNK2019: symbole externe non résolu _gpib_error_stri
ng référencé dans la fonction _Java_linuxgpibJNI_gpib_1error_1string@12
linux-gpib_wrap.dll : fatal error LNK1120: 74 externes non résolus

The symbols not found are those described by ni488.h, so I suppose that the gpib-32.obj library is not used by the linker. Any idea why?

Sorry if this is a basic question, but I haven't used a C compiler for years, and I cannot find my mistake....

Regards

Cyril


0 Kudos
Message 1 of 7
(4,608 Views)
I've just noticed that a similar thread already exists in the forum (sorry for the duplicate, but I swear I looked for it before my post and couldn't find it). Anyway, there is no reply on the other post either...

http://forums.ni.com/ni/board/message?board.id=140&thread.id=27896
0 Kudos
Message 2 of 7
(4,606 Views)
Look like nobody can answer us 🙂

0 Kudos
Message 3 of 7
(4,592 Views)

Hi,

Have you got gpib-32.obj in your project?

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 4 of 7
(4,575 Views)
Hi,

I don't really have a project, as I compile and link the file from the command line. This is because I started with minGW, then moved to visual C, as most documentations mention it. Also, I'd like to integrate the compilation process this in a makefile, because I want it to be as consistent as possible with the linux counterpart.

So if the question is "do you have gpib-32.obj on your computer", the answer is yes. As you can see in my first message, I include it in the call to the linker. However, I get the same error log if I ommit gpib-32.obj when I run the linker.

Cyril
0 Kudos
Message 5 of 7
(4,569 Views)

Ah Ok,

then you just have to provide the correct path to the obj file as a parameter to the linker command.

Regards

Ray

Regards
Ray Farmer
0 Kudos
Message 6 of 7
(4,561 Views)
Hi,

Thank you for your answers. I finally got it to work, and I think my main error (maybe there was several) was to use the wrong header file (ib.h from the linux libgpib instead of ni488.h) Both header files are supposed to implement the same functions, but apparently they're not exchangeable. The functions declared in ib.h and ni488.h look very similar, but I suppose they're not quite the same.

I also used the visual studio ide instead of the command line (your posts convinced me to try that), which is a good idea because there is very little documentation about visual C on command line. When you're used to programming on linux, this is quite surprising.

For the record, here are the two command lines that work to compile my wrapper (options generated by visual studio). Note that this compiles without error, but I'haven't tested the library yet:

cl /Od /I "C:\Program Files\Java\jdk1.6.0_04\include\win32" /I "C:\Program Files\Java\jdk1.6.0_04\include" /I "C:\Program Files\National Instruments\NI-488.2\Languages\Microsoft C" /I "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "_WINDLL" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Wp64 /ZI /TC /errorReport:prompt gpib_wrap.c

link .\debug\gpib_wrap.obj /OUT:"C:\Documents and Settings\cbuttay\Mes documents\Visual Studio 2005\Projects\gpib_wrapper\Debug\gpib_wrapper.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib" /LIBPATH:"C:\Program Files\National Instruments\NI-488.2\Languages\Microsoft C\gpib-32.obj" /DLL /MANIFEST /MANIFESTFILE:"Debug\gpib_wrapper.dll.intermediate.manifest" /DEBUG /PDB:"c:\documents and settings\cbuttay\mes documents\visual studio 2005\projects\gpib_wrapper\debug\gpib_wrapper.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib "c:\program files\national instruments\NI-488.2\Languages\Microsoft C\gpib-32.obj"



0 Kudos
Message 7 of 7
(4,555 Views)