Linker error in Borland C++ when compiling

Posted on 1997-07-19
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.
Question by:shjensen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 1252296
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").

Author Comment

ID: 1252297
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

Expert Comment

ID: 1252298
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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 1252299
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.


LVL 15

Accepted Solution

Tommy Hui earned 400 total points
ID: 1252300
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.

Author Comment

ID: 1252301
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.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question