From: Alexander Borghgraef Newsgroups: comp.os.msdos.djgpp Subject: Re: Newbie question: Linking in RHide Date: Wed, 21 May 1997 19:51:12 +0200 Organization: Universiteit Gent Lines: 59 Message-ID: <33833610.479A@eduserv2.rug.ac.be> References: <33814CF5 DOT F50 AT eduserv2 DOT rug DOT ac DOT be> <338220AE DOT 3DD0 AT eduserv2 DOT rug DOT ac DOT be> <5lu6b3$jnc AT news DOT ox DOT ac DOT uk> NNTP-Posting-Host: hades167.rug.ac.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk George Foot wrote: > 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. > Ok, let me explain the problem a bit more in detail: My program(an astrophysics project) consists of the following files: file1.cc (main program) file2.h (celestial body classes with alot of inline functions) file2.cc (implementation of the above) vector.h (vector class with some inline functions + implementation and 5 friend functions without implementation) vector.cc(implementation of the above friend functions) The functions that are giving me trouble are two of the above mentioned friend functions. In vector.h is written friend vector X_Rotation(vector a, double alfa); friend vector Y_Rotation(vector a, double alfa); friend vector Z_Rotation(vector a, double alfa); These functions represent a rotation of the vector a around the X(Y orZ) axis over an angle alfa. Vector.cc contains the lines #include "vector.h" and the implementation of the above mentioned 3 functions and the 2 others that don't give any trouble. In file2.cc two of these rotation functions are used in the following manner: vector V = X(orZ)_Rotation(W, Angle); Now I'm pretty sure that this is the place where the undefined reference error occurs, since this error message only appears for X_Rotation and Z_Rotation, and not for Y_Rotation, which never gets used in my program. I can't really see the error here, please explain me what the problem might be. I hate to keep bothering people with this, but since this is my first C++ program, I'm quite stuck here. Can't see if it works and I'm getting very close to my deadline here. Heeeeeeeeeeeeeeeeeelp! A.B. -- Darn right! No government should be allowed to keep a tax-paying, god fearing citizen from strapping a couple hundred thousand Estes rocket motors to a kerosene tanker with the hope she'll make orbit. If it lands on some stupid, third world country, well it serves them right for not investing in an ABM system! - Someone in sci.space.policy -