|
From: Opacki, J. <Jos...@ng...> - 2003-09-30 17:04:37
|
Reid, I got it working finally. Thanks for all the help. This is all still new to me. I am still having a small bit trouble understanding friends and overloading operators, especially the use of const. Got any sites for me? Thanks Joseph -----Original Message----- From: Reid Thompson [mailto:Rei...@at...] Sent: Tuesday, September 30, 2003 12:19 PM To: Opacki, Joseph; dev...@li... Subject: RE: [Dev-C++] Newbie: Linker Errors for some reason it is not linking in compile.o My compile log: Compiler: Default compiler Building Makefile: "C:\Downloads\jnk\Makefile.win" Executing make clean rm -f main.o compile.o jnk1.exe g++.exe -c main.cpp -o main.o -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" g++.exe -c compile.cpp -o compile.o -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" g++.exe main.o compile.o -o "jnk1.exe" -L"C:/Dev-Cpp/lib" Execution terminated Compilation successful do this, create a new project using the menu remove the default main.c program created using the menu add files ( your three files ) then build & run reid > -----Original Message----- > From: Opacki, Joseph [mailto:Jos...@ng...] > Sent: Tuesday, September 30, 2003 12:08 PM > To: 'dev...@li...' > Subject: RE: [Dev-C++] Newbie: Linker Errors > > > 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>> > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |