delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/21/11:09:15

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie question: Linking in RHide
Date: 21 May 1997 06:56:35 GMT
Organization: Oxford University, England
Lines: 41
Message-ID: <5lu6b3$jnc@news.ox.ac.uk>
References: <33814CF5 DOT F50 AT eduserv2 DOT rug DOT ac DOT be> <338220AE DOT 3DD0 AT eduserv2 DOT rug DOT ac DOT be>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alexander Borghgraef (aborghgr AT eduserv2 DOT rug DOT ac DOT be) wrote:

: More important, how do I put my program together?

Make sure you have put all the .cc files in the project window, then just
press F9. RHIDE will do the rest for you; compiling and linking. If there
are still undefined references, check:

1) That you have defined the functions/variables referred to

2) That the file defining them is part of the project

In answer to your first question, the unresolved reference error means you
have declared a symbol (e.g. function or variable) but not defined it. A
declaration tells the compiler that the symbol will be defined somewhere
else, and gives it a little information about what the symbol will
eventually be; there may be several (identical) declarations. There must
be one (and only one) definition or each symbol. 

Note the difference between a declaration and a definition; a function
prototype is a declaration, as is an `extern' variable declaration. I
expect you already have these in your code, otherwise you'd get compiler
errors/warnings. The definition of a function is the part which specifies
its body; the definition of a variable is, for example, `int a;' (without
an `extern' before it). 

Incidentally, if you forget to declare a function, but use it anyway in
your code, the compiler will attempt to construct a prototype for it,
usually (thankfully) failing miserably. Make sure that the functions in
file3.cc which you want to make available to other files are indeed
correctly prototyped in appropriate header files.

Turning on `-Wall' helps a lot in this process, as it generates warnings
on implicit declarations of functions (i.e. when you call them before you
declare them). This is (IIRC) in Options->Compiler->Warnings.

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

What's the wizard's password for? (dunnet)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019