Help with compiler error for self-teacher

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2009
Posts: 2
Reputation: fatalbert55 is an unknown quantity at this point 
Solved Threads: 0
fatalbert55 fatalbert55 is offline Offline
Newbie Poster

Help with compiler error for self-teacher

 
0
  #1
Jul 1st, 2009
Hello All,

I am trying to learn C++ on my own, but I think I am having some problems with Code::Blocks. I am familiar with Java (I did some CS as an undergrad) and I feel that the C++ basics are pretty easy to translate from Java; however, I am having problems with my compiler and it has been quite frustrating. My problem is as follows: I am using the Accelerated C++ book to learn since I am already familiar with OOP. I did a program from one of their chapters that uses header files (it's a gradebook code). The compiler keeps giving me "undefined reference to" errors (e.g. "undefined reference to 'read(std::istream&, Student_info&)' and the exact compiler error is listed at the end of this post) when I compile. I define the function read in the *.c file and I've done everything like the book says (looking for any misspelled word, etc). I can include the code if needed, but I thought I would see if it was something simple that I had forgotten (the code is a little lengthy). Also, all the files are in the same directory. Any help would be much appreciated. I attached the code to this message. Another problem, and I don't know if this is related, when I try to compile the *.cpp files one by one, I usually get a "C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\libmingw32.a(main.o):main.c:(.text+0x104)||undefined reference to `_WinMain@16'|" error. Thanks so much!

Allen

C:\Documents and Settings\Allen\My Documents\C++ Work\Grade_Project\gradeCalc.o:gradeCalc.cpp:(.text+0x210)||undefined reference to `read(std::istream&, Student_info&)'|
C:\Documents and Settings\Allen\My Documents\C++ Work\Grade_Project\gradeCalc.o:gradeCalc.cpp:(.text+0x28a)||undefined reference to `compare(Student_info const&, Student_info const&)'|
C:\Documents and Settings\Allen\My Documents\C++ Work\Grade_Project\gradeCalc.o:gradeCalc.cpp:(.text+0x414)||undefined reference to `grade(Student_info const&)'|
||=== Build finished: 3 errors, 0 warnings ===|
Attached Files
File Type: cpp grade.cpp (587 Bytes, 2 views)
File Type: h grade.h (266 Bytes, 1 views)
File Type: cpp gradeCalc.cpp (1.6 KB, 2 views)
File Type: cpp median.cpp (643 Bytes, 1 views)
File Type: h median.h (142 Bytes, 0 views)
File Type: cpp Student_info.cpp (813 Bytes, 2 views)
File Type: h Student_info.h (450 Bytes, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,582
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 457
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Help with compiler error for self-teacher

 
0
  #2
Jul 1st, 2009
Dear fatalbert55,

Give me a reason why should I read the attached files. We are here to help somebody; not to provide a complete solution.

Please post the phrase of code where you got problems.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 440
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 68
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: Help with compiler error for self-teacher

 
1
  #3
Jul 1st, 2009
If you are compiling them one-by-one make sure you only compile and don't go to the linking process. I think you might be doing that and while trying to create an executable its not finding main. Read the compiler man pages and find the flag used to only compile and not link. Once everything is compiled you can link the object files together and create the executable.
Last edited by Agni; Jul 1st, 2009 at 10:55 am.
thanks
-chandra
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 2
Reputation: fatalbert55 is an unknown quantity at this point 
Solved Threads: 0
fatalbert55 fatalbert55 is offline Offline
Newbie Poster

Re: Help with compiler error for self-teacher

 
0
  #4
Jul 1st, 2009
Thanks Agni! That did the trick!

adatapost: I didn't include snippets of code because it wasn't a part of the code that was causing the problem. I was having problems with the compiler.

Thanks all for helping out the newb!

Allen
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC