Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

MinGW on Windows 7 64bit and DAQmx 9.1.7

I tried posting this on the old thread: http://forums.ni.com/t5/Multifunction-DAQ/How-Can-I-Use-The-NI-DAQmx-ANSI-C-Function-Library-With-GC... 

 

but i have recieved no replies.  i basically followed all the instructions in that thread but still cannot get it to work on Windows 7 64bit and DAQmx 9.1.7.

 

I have been trying to get this to work for the last 2 days but cannot.  Maybe someone can help me.  Let me explain my setup first;

 

windows 7 64bit

nidaqmx 9.1.7

mingw 64 bit

 

I can create the def file (from C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\lib64\msvc\nidaqmx.lib) wich i have attached.  Although it does not have the @ symbols in it.  Is it correct?

 

I then ran dlltool and created the libnidaq.a file which i used in my linker.

 

Everything works up to there.  The problem is when i try to build i get the following error:

 

c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `../../Createdef/libnidaq.a(dyyrh.o)' is incompatible with i386:x86-64 output
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `../../Createdef/libnidaq.a(dyyrt.o)' is incompatible with i386:x86-64 output
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/libHelloWorldC.dll] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

 

I am pretty sure everything is 64 bit so i don't know where this error is coming from.

 

Any help would be greatly appreciated.

0 Kudos
Message 1 of 14
(4,588 Views)

It looks like it's a problem with the dlltool not creating libnidaq.a correctly. Are you using the regular dlltool or the 64-bit version?

 

Brice S.

Applications Engineer

National Instruments

www.ni.com/support

 

0 Kudos
Message 2 of 14
(4,571 Views)

I don't think you need to create a mingw-specific import library. Just link directly against nicaiu like any other library.

 

This page says you only need to use dlltool when you want to specify a custom .def file: http://www.mingw.org/wiki/CreateImportLibraries

 

Here's a hacked up version of /cygdrive/c/Users/Public/Documents/National Instruments/NI-DAQ/Examples/DAQmx ANSI C/Analog In/Measure Voltage/Acq-Int Clk/Makefile that seems to work for me but is not officially supported:

 

SHELL = /bin/sh

LIBS = nicaiu
LIBFLAGS = -L/cygdrive/c/windows/sysnative -l$(LIBS)
TARGET = Acq-IntClk

OBJS = $(TARGET).o

CC = x86_64-w64-mingw32-gcc
CDEBUG = -g
LDFLAGS += -g

CFLAGS += $(CDEBUG) -I"/cygdrive/c/Program Files (x86)/National Instruments/Shared/ExternalCompilerSupport/C/include"

all: $(TARGET)

clean:
    rm -f $(OBJS) $(TARGET) core

$(TARGET) : $(OBJS)
    $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBFLAGS)

 

I just built a 64-bit mingw version of this example and was able to see the API calls in NI I/O Trace. There were some stdio buffering issues, so the resulting program didn't produce any output until I pressed the enter key. Your mileage may vary.

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 3 of 14
(4,563 Views)

Thanks for the replies guys.

 

I finally got it to work (in terms of building the library file) using the method from the link i posted to the old post about this issue.

 

There must have been something messed up because i just started from sctratch again and it worked.

 

Now i have other issues with DAQmxCreateTask with the JNI.  i get an EXCEPTION_ACCESS_VIOLATION every time.

0 Kudos
Message 4 of 14
(4,557 Views)

I am using the 64 bit version that comes with the 64 bit version of MinGW.

0 Kudos
Message 5 of 14
(4,556 Views)

Hi wewe,

 

Here are a few ideas about why the first call to DAQmxCreateTask might raise an access violation:

  • Calling convention mismatch between your program/import library and nicaiu.dll
  • Typedef/function signature mismatch between your program and nicaiu.dll
  • Invalid pointer arguments (note that 'taskHandle' is an out-parameter so DAQmx will write to the memory that 'taskHandle' points to)

Try building a simple C test program to rule out these possibilities before trying to integrate DAQmx with your JNI library.

 

As previously mentioned, creating a custom import library appears to be unnecessary nowadays. Modern versions of mingw can link against most DLLs directly without a custom import library. Try passing "-lnicaiu" to the compiler.

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 6 of 14
(4,545 Views)

Brad,

 

I finally had an opportunity to try out your suggestions and you are absolutely right.  It is not necessary to create a custom import library.

 

Everything is kinda working now.  I still cannot pass taskHandle to Java since the type does not exist in Java.

 

Thank you for the great support.

0 Kudos
Message 7 of 14
(4,479 Views)
#include <stdio.h>
#include <string>
#include <iostream>
#include "C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\include\NIDAQmx.h"

using namespace std;

int main()
{
string channelNamestr = "Dev1/ai0";
const char* channelName = (channelNamestr).c_str();
float64		output = 0.0;
TaskHandle  taskHandle=0;
char        errBuff[2048]={'\0'};
double		minimumValue = 0.0;
double		maximumValue = 100.0;

DAQmxCreateTask("ThermoRead",&taskHandle);
DAQmxReadAnalogScalarF64 (0, 10.0, &output, NULL);
DAQmxCreateAIThrmcplChan(taskHandle, channelName,"",minimumValue,maximumValue,DAQmx_Val_DegC,DAQmx_Val_J_Type_TC,DAQmx_Val_BuiltIn,25.0,"");
DAQmxReadAnalogScalarF64 (taskHandle, 10.0, &output, NULL);

return 0;
}

 Hi everyone, I'm new to programming in C++ and just wanted to connect to a USB TC-01 thermo couple using MinGW as compiler. connecting to the USB thermo couple seems to be tricky. I'm not used to load libraries and didn't manage to do so yet following some instructions but only understanding half of it. Is there an easy way for newbies to connect to the thermo couple? I just need the temperature, nothing else 🙂 I tried to copy something together (see code above) but I didn't manage to compile it because the nidaqmx library is missing. I didn't understand how to do it from this thread (some links not working, not understanding why it's a problem to load the dll), is there an easy instruction?

0 Kudos
Message 8 of 14
(4,011 Views)

DeepKling,

 

If all you are doing is trying to read temperature there is an application that comes with the USB-TC01 that you can use to look at temperature. Look over the user guide and follow the instructions to get up and running, it should be pretty simple.

 

DAQmx is a driver that National Instruments Data Acquisition devices use, however the TC-01 is simple enough that you don't necessarly have to use the DAQmx driver to use the device. You should automatically get a TC01 Launch Screen at startup.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 9 of 14
(3,998 Views)

Thanks for the quick reply! yes I saw the temperature log tool, but what I want to do is reading in the temperature in a c++ program that is evaluating sublimation curves. It's my third c++ program, so it uses only simple functions. however, I managed to make it connect to all the hardware (via COM port, using a lib) and creating output with gnuplot, fitting the curves and calculating the sublimation enthalpy and so on. The only hardware I can't make connect is the USB TC... So what I need is a way to contact the TC with c++, but I don't get the lib thing... the lib needs to be converted in order to use it? How do I do that with MinGW (not using cygwin)?

The reason why I use g++ is that I'm running Ubuntu at home and don't want to use visual c++ (for possible linux ports), I also tried to make it work in visual c++ and failed. All the instructions I found so far where either using some dead links, were written for old versions or where too hard for me to follow 🙂

0 Kudos
Message 10 of 14
(3,993 Views)