From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

using C++ in place of Labview

Solved!
Go to solution

Hi,

I want to use C++ to interact with NI modules.

I have visual studio installed and can run C++ programs without any issue.

But when I use commands like DAQmxCreateTask, it gives me error "identifier "DAQmxCreateTask"" is undefined.

What steps I should be taking to make it working? How can I find what is missing here?

0 Kudos
Message 1 of 5
(2,646 Views)

You need to include the "nidaqmx.h" header file. And add the location of the NI header files to the project or Visual C configuration. C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\Include.

 

Last but not least you need to add the "NIDAQmx.lib" file to the Additional Libraries in the Linker Settings and also add the path C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\Lib32\MSVC as additional Library path to the Linker Settings. Replace Lib32 with Lib64 if your target is to be compiled as 64-bit code.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(2,617 Views)

Thank you very much. 

I am new to C++ so if you can explain in detail, that will help me a lot.Here is what I see.

You need to include the "nidaqmx.h" header file. And add the location of the NI header files to the project or Visual C configuration. C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\Include-I see file nidaqmx.h in the folder C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\Include  ..How can I add the location of the NI header files to the project or Visual C configuration?

add the "NIDAQmx.lib" file to the Additional Libraries in the Linker Settings-- Found NIDAQmx.lib at 3 places, 2 in National Instruments \shared\externalcompilersupport\C\lib32\msvc and 1 in National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc.  Just typed NIDAQmx.lib in Linker\Input\Additional Dependencies\Edit window

add the path C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\Lib32\MSVC as additional Library path to the Linker Settings-Could not find additional library path setting

Replace Lib32 with Lib64 if your target is to be compiled as 64-bit code.-Found files Lib32 and Lib64 in folder National Instruments\Shared\External CompilerSupport\C .Did not get exactly what I am supposed to do here.

 

Sorry this may be very basic level for you, but for me, I was always using Labview and was never exposed to C++ (particularly NI with C++).Just want to start with using C++ as well.

 

0 Kudos
Message 3 of 5
(2,589 Views)
Solution
Accepted by maccapple

@maccapple wrote:

 

Sorry this may be very basic level for you, but for me, I was always using Labview and was never exposed to C++ (particularly NI with C++).Just want to start with using C++ as well.

 


My first question would be: Why do you want to go the C programming path then?

These are standard C things that you need to know about in every C programming environment you would use. Aside from the exact paths to use, there is absolutely nothing that is specific to use with NI software in general nor DAQmx in general. How and where to apply these settings depends per C development environment but remains principially the same.

 

Including a header file is simply adding the according

 

 

#include "<your header file>"

 

 

to the top of your source file. In order for the compiler to be able to find the location where this file is located you need to add the according directory to the environment or project settings.

 

The functions referenced to in the header file need to be implemented somehwere, which is inside the according link library (*.lib) file. This has to be added to the linker settings for your project and in order for the compiler/linker to be able to locate that file you need to add the correct directory to the linker options too.

 

Last but not least if your project is targetting 32-bit compilation you need to link the 32-bit version of the lib with your executable, for 64-bit this has to be the 64-bit version. This could be solved by naming the link libraries differently but often is solved by leaving the name of the link library the same and change the path in which the linker should look for that library.

 

If this is still all Spanish for you you may first want to do a C programming course for your programming environment before venturing into writing a C program.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 5
(2,582 Views)

We have several applications running with different software. Company wants someone who can  understand these, as these programs are already running.

I can simply follow your instructions, but as you suggested, before doing this, I'll first try to get deeper into C programming environment, so that I know what I am doing. Thanks for your help .I've saved your instructions and I am sure these will lead me to successfully control NI modules with C++.

0 Kudos
Message 5 of 5
(2,572 Views)