Solved

Linker error in Borland C++ when compiling

Posted on 1997-07-19
6
1,671 Views
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",
iIgnoreWarning);
    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
#endif

#ifdef __cplusplus
extern "C" {
#endif


/* 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.
0
Comment
Question by:shjensen
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:AVaulin
Comment Utility
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").
0
 

Author Comment

by:shjensen
Comment Utility
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

soren


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
0
 
LVL 4

Expert Comment

by:AVaulin
Comment Utility
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:shjensen
Comment Utility
Hi AVaulin

I'm quite sorry but I still cant get it to work, I have transfered the files to the ftp address :
ftp://ftp.netcorps.com/pub3/pndler/
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:
TARGET TYPE:
application.exe
PLATFORM :
dos(standard)
TARGET MODEL:
medium
STANDARD LIBRARIES:
runtime
emulation

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.

Sincerely,

soren
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 400 total points
Comment Utility
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.
0
 

Author Comment

by:shjensen
Comment Utility
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.

soren
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now