We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Linker error in Borland C++ when compiling

shjensen asked
Medium Priority
Last Modified: 2008-02-26
I am running broland c++ 4.0 under win 95. I am trying to compile a small program called AI1pt.c that reads an A/D channel of an A/D card (PC-LPM-16). The program comes as a 3. party software product with the NIDAQ package from National Instruments. The little program uses other driver files, but apparantly when it tries to use the functions of the include files it fails. Here is the program ai1pt.c

#include "nidaqex.h"

void main(void)
     * Local Variable Declarations:

    i16 iStatus = 0;
    i16 iRetVal = 0;
    i16 iDevice = 1;
    i16 iChan = 1;
    i16 iGain = 1;
    f64 dVoltage = 0.0;
    i16 iIgnoreWarning = 0;

    iStatus = AI_VRead(iDevice, iChan, iGain, &dVoltage);

    iRetVal = NIDAQErrorHandler(iStatus, "AI_VRead",
    if (iStatus == 0) {
        printf(" The voltage at AI channel %d is %lf volts.\n", iChan, dVoltage);


When compiling I get the following error messages :
Linker Warining : No module definition file specified : using defaults

Linker error : Undefines symbol AI_VRead in module AI1pt.c

Linker error : Undefined symbol Owlmain (int, char, far*far*) in library file c:\bc4\lib\owlwi.lib in module winmain.

Here is parts of the nidaq.h file that is being called :

#ifndef _NIDAQ_Header_
#define _NIDAQ_Header_

*    NI-DAQ Windows - Function Prototypes
*    Copyright    (C) National Instruments 1995.

typedef char i8;
typedef unsigned char u8;
typedef short i16;
typedef unsigned short u16;
typedef long i32;
typedef unsigned long u32;
typedef float f32;
typedef double f64;

#ifndef FAR
#define __locallydefinedFAR
#define FAR

#ifdef __cplusplus
extern "C" {

/* some parts of program cut out here */
extern i16 WINAPI AI_VRead (
      i16        slot,
      i16        chan,
      i16        gain,
      f64        FAR * volts);
/* End of program */
/* some parts of program cut out here */

If any further informtion is needed to answer this question, then please dont hesitate to call me.

soren jensen

ps any help on solving this problem, will relly make me happy, but in case you dont give it a try, then thanks for taking a look at it.
Watch Question

As for first linker error: be sure that NI-DAQ lib file included into project. As for second one: you are use "main" function but you must use "WinMain" or "OwlMain" function instead "main" (when your project is OWL-based you must use "OwlMain").


Hi AVAulin

Thanks for taking your time to comment my question, I am truely happy for you helping me out. However, I am not an expert and dont understand most of your answer. I think my main problem is the : Undefined symbol AI_VRead in module AI1pt.c error message. Because, if I cant use the functions in the NiDAQ include file, I cant meassure anything from the A/D card. It somehow looks like the compiler doesnt understand that I have included the file nidaqex.h and therefore I cant use the functions of that file.

Since the program comes with the NiDAQ dirvers as 3. party software, I dont see any reason why I should change to OwlMain or WinMain, cause why would they send you some files that dont work. I have the nidaqex.h file in the include path (folder)of Borland along with all the other include files that the program needs (in the nidaq.h. file there are sevaral other include files). The hole purpose of this program is to make on single A/D conversion, I want to call this C-program from a perl script (having setup my win95 computer as an internet server and using a graphical interface made in HTML), and have the value returned for to my perl script. I dont want any windows "crap" opening up. I am a novice when it comes to programming in C/C++ and windows, and to be honest I dont really understand what I am doing right now.
I am affraid that you have to help me out a little more before I will evaluate your answer, though I am sure that someone more experienced would have understood your answer.

Greetings from Perris CA


ps I tried to  change main to winmain and owlmain, but that just produced more errors. I still get the undefined AI_VRead module in AI1PT.C

pps I you want me to I  would be happy to send you all the files needed to run this little program

You must understand next: header (.h) files only declares functions prototypes. Any compiler needs prototypes to be possible to compile source code (ie check syntax and create obj files). After compiler finishs process linker begin to try to make exe file. For that time linker needs all functions realizations (they stored in obj and lib files). So linker needs any AI_VRead realizarion. To the point: you are use printf function. This function prototype is in <stdio.h> file and realization is in one from "standard" library - CL.LIB (you can find it in LIB directory of your compiler). So look to the files which 3 party software contains, find LIB or OBJ file(s) and include it(them) to project.
Good luck.


Hi AVaulin

I'm quite sorry but I still cant get it to work, I have transfered the files to the ftp address :
Then you can take a look at my problem if you like, btw transferred .lib in both ascii and binary since I am not sure what format it is. Pls. find all include files and lib files from the 3. party software package uploaded in /lib and /include
Now back to your answer, thanks for telling me that header files declare prototypes, none of my books ever explained that quite obvious statement, I was always confused on some programs having prototypes declarations and others not having any.

I already had all include and lib files copied to the lib and include path of borland, but I still get the errors:

linking AI1PT.EXE
Linker warning : no module definition file specified : using defaults.
Linker error : Undefined symbol NIDAQERRORHANDLER in module AI1PT.C
Linker error : Undefined symbol AI_VRead in module AI1PT.C

The preiviously mentioned owlmain error I only get when trying to compile the program as a windows program, when trying to compile as a dos I get the above errors.

I have the following options on in the project file menu:

I do the following when I try to run the program :
open up a new project and choose the above mentioned options, then I load in the AI1pt.c program and try to run it.

Please try to help me out once more, I really apreciate it.


You will need to add the library into your project file. I don't have the Borland IDE anymore, but you need to go to your project window and hit the insert key. It will bring up the project window and ask you which files you want to insert into the project. Select the library file you need. This is determined by the supplier of the library. For 16-bit programs, they would typically have more than one and it is depending on memory model. So the name of the library would be something like NiDaqm.lib or something like that.

You cannot just add the path to the library into the project because the linker does not look at every single library in its paths. That would take way too long. So instead, it is your job to tell it which files you need for this project and you do that by using the above method. Alternatively, you can use the menu Add To Project from the Project menu.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Hi Thui

Thanks for trying to help me out here, I have already "included" all the .lib and .h files into my ide project, but still I get the undefined symbol AI_VRead in module ai1pt.c error message. It seems to me that I have tried most everything. I got about 20 pages of the borland homepage on the linker error messages, but it did not help. I have a feeling that my problem is just a little insignificant thing that I have overlooked, I am not a routined C programmer so it could definately be the case.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.