This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Using NI-DAQmx ANSI C Function Library with Borland C and Delphi

Updated Oct 4, 2019

Reported In

Software

  • LabWindows/CVI Base

Driver

  • NI-DAQmx

Issue Details

I am using the NI-DAQmx ANSI C functions with my Borland compiler, but none of the C functions will compile. The Borland compiler is a ANSI standard compiler. Why don't the functions work?

Solution

NI-DAQmx 15 and up does not include the C import library for Borland.

NI-DAQmx until version 14 included C import library for Borland. This import library is only installed with NI-DAQmx ANSI C support. In earlier versions, the import library was only installed with NI-DAQmx LabWindows™/CVI™ support. This is because the import library is used when LabWindows/CVI is running in Borland compatibility mode or when LabWindows/CVI users use Borland as their external compiler. You should be able to compile your applications against the NIDAQmx.h header file and link against the appropriate version of the import library. 

In current versions of NI-DAQmx, this import library is included with NI-DAQmx ANSI C support, and the import library is located here:
  • (32-bit OS): C:\Program Files\National Instruments\Shared\CVI\ExtLib\borland\NIDAQmx.lib
  • (64-bit OS): C:\Program Files (x86)\National Instruments\Shared\CVI\ExtLib\borland\NIDAQmx.lib
  • (earlier versions) C:\Program Files\National Instruments\CVI80\extlib\borlanNIDAQmx.lib
If you did not install ANSI C support originally, then you can use the Windows Control Panel to Modify the NI-DAQmx installation to include ANSI C Support. Once in Control Panel, go to Programs then Programs and Features. Select National Instruments Software in the list of programs. Double-click or click Uninstall/Change. This will open another window with a list of all National Instruments software. Select your version of NI-DAQmx and click Modify. This will prompt you to find the location of the installer, which will be the driver DVD, a location on a server, or (if you downloaded the driver from online) C:\National Instruments Downloads\NI-DAQmx\[version] , where [version] is your version of NI-DAQmx. This will launch the NI-DAQmx installer and bring you to a list of features. Expand the items to NI-DAQmx [version]»Applications Development Support»ANSI C Support. please make sure the ANSI C support is selected to install. If it is not, use the drop down to select Install this feature to local drive. The result should look like the following image:

    Another workaround is to download the evaluation version of LabWindows/CVI from ni.com/lwcvi/download/  and then install the NI-DAQmx ANSI C support, as mentioned above.

    Please be aver, that in versions of LabWindows/CVI higher than 9.0, National Instruments does not support Borland compilers.

     

    Additional Information

    If you are experiencing error -50251:
    When compiling your NI-DAQ application in Borland, you may run into error -50251. This is a floating point exception error that has to do with the way floating point numbers are masked. Apparently, this happens quite frequently when Borland-built applications use components built with non-Borland compilers. For example, when you try to use OpenGL from Delphi, the same type of exception will occur. Most compilers manage floating point error conditions internally under defined rules. However, a number of compilers will always unmask these exceptions in order to enable the compiler's proprietary error handling mechanisms. By default, Borland Delphi exposes floating point conversion errors, and certain DAQmx calls returning these errors cause the DLL to crash. To handle these errors one must hide or mask the handful of different error cases that might be encountered. If you fail to mask the exceptions, they make their way to the operating system which will display an error message and then shut down the DLL. Use the following instructions before calling any DAQ function to mask the FPU exceptions. This issue has been fixed in NI-DAQmx 7.4.

    In your Borland C application that uses NI-DAQ 7.3 or earlier, you need to add:

    _control87(MCW_EM,MCW_EM)

    to your initialization code as follows:

    #include
    main() {
    _control87(MCW_EM,MCW_EM);
    .
    .
    .
    }