Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

mingw C++ linker error: VISA on Windows 10

Hi

 

I tried to add VISA support on a small program on Windows 10, compiled with mingw (C++). But I have a problem with the linker who failed to link all the functions(error undefined reference to `LeaveCriticalSection@4')

 

My code (simplified)

#include "C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Include\visa.
.....
ViSession defaultRM;
ViStatus status = viOpenDefaultRM(&defaultRM);
 if (status == VI_SUCCESS) {
  status = viOpen(defaultRM, "GPIB0::2::INSTR", VI_NULL, VI_NULL, &instr);
 } 
.....

The makefile

 

CXXFLAGS += -I/C/Progra~2/IVI~1/VISA/WinNT/Include
LDLIBS += -L/C/Windows/System32 -lvisa32

The error message:

 

 

g++.exe -Wall -g -I/C/bin -I/C/Progra~2/IVI~1/VISA/WinNT/Include    -shared -o libUserCode.dll nivisa.o prologix.o qpx1200sp.o usercode.o -L/C/MuTest/bin -lmttnative -lDSP_Library -L/C/Windows/System32 -lvisa32 
Warning: resolving _GetModuleHandleA@4 by linking to _GetModuleHandleA
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _GetProcAddress@8 by linking to _GetProcAddress
Warning: resolving _viOpenDefaultRM@4 by linking to _viOpenDefaultRM
Warning: resolving _viOpen@20 by linking to _viOpen
Warning: resolving _viClose@4 by linking to _viClose
Warning: resolving _Sleep@4 by linking to _Sleep
Warning: resolving _VirtualQuery@12 by linking to _VirtualQuery
Warning: resolving _VirtualProtect@16 by linking to _VirtualProtect
Warning: resolving _EnterCriticalSection@4 by linking to _EnterCriticalSection
Warning: resolving _TlsGetValue@4 by linking to _TlsGetValue
Warning: resolving _GetLastError@0 by linking to _GetLastError
Warning: resolving _DeleteCriticalSection@4 by linking to _DeleteCriticalSection
Warning: resolving _InitializeCriticalSection@4 by linking to _InitializeCriticalSection
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libmingw32.a(tlsthrd.o): In function `_mingwthr_run_key_dtors':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/tlsthrd.c:117: undefined reference to `LeaveCriticalSection@4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libmingw32.a(tlsthrd.o): In function `__w64_mingwthr_add_key_dtor':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/tlsthrd.c:59: undefined reference to `LeaveCriticalSection@4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libmingw32.a(tlsthrd.o): In function `__w64_mingwthr_remove_key_dtor':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/tlsthrd.c:93: undefined reference to `LeaveCriticalSection@4'
C:\MinGW\msys\1.0\src\mingwrt/../mingw/tlsthrd.c:93: undefined reference to `LeaveCriticalSection@4'
collect2: ld returned 1 exit status
make: *** [libUserCode.dll] Error 1

Several functions was linked, but not all.

Any ideas ?

 

Thanks in advance

0 Kudos
Message 1 of 4
(4,849 Views)

 Hello,

 Windows 10 is supported by NI VISA 15.5, but we don't support c++ : http://download.ni.com/support/softlib//visa/NI-VISA/15.5/Windows/readme.html

we only support c# with .NET

 

Best regards

 

Audace MUDRY

0 Kudos
Message 2 of 4
(4,808 Views)

thanks for your response.

 

I just try with Windows 7 Pro SP1, and the the problem is the same.

0 Kudos
Message 3 of 4
(4,801 Views)

may try belows for 64bits, Windows 10, msys2

 

g++ test.cpp -o test.exe -I /c/Program\ Files/IVI\ Foundation/VISA/Win64/Include/ -L /c/Program\ Files/IVI\ Foundation/VISA/Win64/Lib_x64/msc/ -lvisa32
0 Kudos
Message 4 of 4
(1,555 Views)