|
From: Opacki, J. <Jos...@ng...> - 2003-09-30 16:08:21
|
Reid
I'm not getting the same errors... My errors do not say a line number and
only appear as such:
[Linker error] undefined reference to `DigitalTime::DigitalTime()'
[Linker error] undefined reference to `operator>>(std::istream&,
DigitalTime&)'
[Linker error] undefined reference to `DigitalTime::advance(int)'
[Linker error] undefined reference to `operator==(DigitalTime const&,
DigitalTime const&)'
[Linker error] undefined reference to `operator<<(std::ostream&, DigitalTime
const&)'
[Linker error] undefined reference to `DigitalTime::advance(int, int)'
Here's my compiler log:
-------------------------------------------------------
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\compile\main.cpp" -o "C:\compile\main.exe"
-I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32"
-I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include"
-L"C:\Dev-Cpp\lib"
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x134):main.cpp:
undefined reference to `DigitalTime::DigitalTime()'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x143):main.cpp:
undefined reference to `DigitalTime::DigitalTime()'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x16c):main.cpp:
undefined reference to `operator>>(std::istream&, DigitalTime&)'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x189):main.cpp:
undefined reference to `DigitalTime::advance(int)'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x19c):main.cpp:
undefined reference to `operator==(DigitalTime const&, DigitalTime const&)'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x1e2):main.cpp:
undefined reference to `operator<<(std::ostream&, DigitalTime const&)'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x218):main.cpp:
undefined reference to `operator<<(std::ostream&, DigitalTime const&)'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x234):main.cpp:
undefined reference to `DigitalTime::advance(int, int)'
C:\DOCUME~1\opackjo\LOCALS~1\Temp/ccEVaaaa.o(.text+0x261):main.cpp:
undefined reference to `operator<<(std::ostream&, DigitalTime const&)'
Execution terminated
-------------------------------------------------------
-----Original Message-----
From: Reid Thompson [mailto:Rei...@at...]
Sent: Tuesday, September 30, 2003 11:25 AM
To: Opacki, Joseph; dev...@li...
Subject: RE: [Dev-C++] Newbie: Linker Errors
if these are the messages you are getting:
compile.cpp: In member function `void DigitalTime::advance(int, int)':
compile.cpp:56: `hourAdded' undeclared (first use this function)
compile.cpp:56: (Each undeclared identifier is reported only once for
each
function it appears in.)
compile.cpp: In function `std::ostream& operator<<(std::ostream&, const
DigitalTime&)':
compile.cpp:63: `theOjbect' undeclared (first use this function)
compile.cpp: In function `std::istream& operator>>(std::istream&,
DigitalTime&)':
compile.cpp:73: `readHours' undeclared (first use this function)
compile.cpp: In function `void readHour(std::istream&, int&)':
compile.cpp:127: `thehour' undeclared (first use this function)
make.exe: *** [compile.o] Error 1 Execution terminated
Then you need to declare each of these missing values( or spell them as
they have been declared ).
hour = (hour + hourAdded)%24; should hourAdded be hoursAdded per
void DigitalTime::advance(int hoursAdded, int minutesAdded)
if (theOjbect.minute < 10) -> as above spelling counts
readHours(ins, theObject.hour); -> ditto
readHours(ins, theObject.hour); -> ditto
reid
> -----Original Message-----
> From: Opacki, Joseph [mailto:Jos...@ng...]
> Sent: Tuesday, September 30, 2003 10:17 AM
> To: 'dev...@li...'
> Subject: [Dev-C++] Newbie: Linker Errors
>
>
> I'm still learning so please be patient.
>
> I am running into some problems. I've defined my interface
> file as "compile.h", my implementation file as "compile.cpp",
> and my application file as "main.cpp". The implementation
> and application files both contain [ #include "compile.h" ].
> However, when I try to compile my application file, I receive
> numerous linker errors with undefined references to my class.
>
> HELP!
>
> Am I not understanding the whole seperate file compilation?
> Isn't the class interface and implementation files supposed
> to be named the same and just with different extensions?
>
> I've attached all three files...thanks.
>
> Joe <<compile.cpp>> <<compile.h>> <<main.cpp>>
>
|