06-01-2006 05:05 PM
06-02-2006
06:25 PM
- last edited on
07-15-2025
01:35 PM
by
Content Cleaner
I haven’t had an experience with that specific compiler, but here is an excerpt from the DAQmx C Reference Manual that should help a bit:
Creating an ANSI C Application without LabWindows/CVI
NI-DAQmx has a C API that you can use to create applications. To create an application, follow these general steps:
Create a new project.
Open existing or new source files (.c), and add them to the project. Make sure you include the NI-DAQmx header file, nidaqmx.h, in your source code files. You can find this header file at NI-DAQ\DAQmx ANSI C Dev\include.
Add the NI-DAQmx import library, nidaqmx.lib, to the project. The import library files are located under NI-DAQ\DAQmx ANSI C Dev\lib\.
To view examples of NI-DAQmx applications, go to the NI-DAQ\Examples\DAQmx ANSI C Dev directory.
Build your application.
Also, if you are just looking for something to program your 6008 with, you can download a free evaluation copy of LabVIEW from this website. There are tons of LabVIEW examples that you can take advantage of as well.
-GDE
06-05-2006 08:37 AM
Thanks.
Actually I can only use NI-DAQmxBase, and I already copied the nidaqmxbase.lib and included the header file nidaqmxbase.h, but the problem is still there. There might be some macro in the header that cannot be recognized by the LCC compiler, but I don't know how to solve it.
06-05-2006
09:25 AM
- last edited on
07-15-2025
01:36 PM
by
Content Cleaner
06-06-2006 07:39 AM
Thanks. I tried to use DAQmx, the problem remains the same, i.e. error showing
undefined reference to _DAQmxCreateTask@8
undefined reference to *******
06-06-2006 10:44 AM
06-06-2006 12:46 PM
Thanks, Jeff.
I tried the following:
"Importing a foreign library" within LCC, created a new "NIDAQmx.lib" based on the original one provided by NI (the original lib is 0.57M, the new one is 1.52M), and put it under the folder "c:\lcc\lib". I also put the header "NIDAQmx.h" under the folder "c:\lcc\include".
Then I tried to MAKE the exe file. Still, the same error happened. LCC still complains the undefined reference to all the _DAQmx* functions.
Here is the source c file I used:
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int error=0;
TaskHandle taskHandle=0;
uInt32 data;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle,"Dev1/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf("Continuously polling. Press Ctrl+C to interrupt\n");
while( 1 ) {
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadCounterScalarU32(taskHandle,10.0,&data,NULL));
printf("\rCount: %d",data);
fflush(stdout);
}
Error:
puts("");
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
06-06-2006 01:48 PM
I just tried to build your example program with lcc, and it worked for me. From the error you are seeing, it seems that either nidaqmx.lib is not in your project, or it is but you are still referencing the msvc one instead of the one you created. I would guess that you are pointing to the msvc library. You might try renaming that one (to something like nidaqmx.msvc), and try rebuilding. Don't forget to change the name back when you are done.
Good Luck
Jeff
06-06-2006 03:55 PM
Thanks a lot, Jeff.
It's working now. I guess I need to add a link to the NIDAQmx.lib when I create the project in LCC. After I did that, the linking got through smoothly.
Thanks again!