|
From: Per W. <pw...@ia...> - 2005-07-16 19:21:16
|
You must make sure that the file Prototypes.cpp (strange file name by the
way since it doesn't contain function prototypes but actual
implementations...) has been added to the project. If not, the compiler
will not compile it (no Prototypes.o generated) and the linker will not
link it.
/Per W
On Sat, 16 Jul 2005, Fred J. wrote:
> Hello
> I have this linker error which makes me think that the
> definition file is not being seen by the linker, this
> code is taken from "Thinking in C++, 2nd Edition,
> Volume 1, Annotated Solutions Guide"
> Using Dev-C++ 4.9.9.2, The error is:
> [Linker error] undefined reference to =91f(int)=92
> all the following files are in the same dir.
>
> thanks
>
> //: S03:Prototypes.h
> void f(int);
> ///:~
>
> //: S03:Prototypes.cpp {O}
> // Implements functions declared in Prototypes.h
> #include <iostream>
> using namespace std;
>
> void f(int i) {
> cout << "f(" << i << ") returning void\n";
> }
> ///:~
>
> //: S03:ProtoTest.cpp
> //{L} Prototypes
> #include <iostream>
> #include "Prototypes.h"
>
> int main() {
> f(1);
>
> getchar();
> return 0;
> }
|