[prog] C++ loader error

Laurel Fan laurel at sdf.lonestar.org
Thu May 29 23:29:50 EST 2003


No idea if this has anything to do with your problem, but I notice
that your makefile uses main.o to build firm, but does not have a rule
to build main.o.  Most likely, a default rule is being used to build
main.o, and it might be doing what you want anyway.  Also, it doesn't
look like your myCompany.o rule will ever be used.

By the way, you can use pattern rules to simplify your makefile.  For
example:

%.o: %.C
	g++ -c $<

Which means that whenever you have a dependency on a whetever.o file,
it will generate a rule for you that looks like:

whatever.o: whatever.C
	g++ -c whatever.C

So it essentially tells make to make any .o file from the matching .C
file.

For more details, the relevant chapter in the GNU make manual is:

http://www.gnu.org/manual/make/html_chapter/make_10.html#SEC108


On Fri, May 30, 2003 at 03:07:28PM +1000, Sue Stones wrote:
> I have written a class heirarcy, and have dealt with complile time errors.  
> But now I am getting a loader error.  I don't know where to look to lllok for 
> errors.   All files are in the current directory (which is in $PATH).
> 
> Any sugestions?   Below are the error message, the makefile, and  main.C
> as I assume that these are the most likely places for the error to occur.
> 
> thanks sue
> 
> 
> _________the beginning of the error messages ________
> $ make
> g++    -c -o main.o main.C
> ld -o firm main.o Firm.o Employee.o Manager.o \
>      Clerk.o Salesperson.o SalesRecord.o
> ld: warning: cannot find entry symbol _start; defaulting to 08048080
> main.o: In function `main':
> main.o(.text+0x9f): undefined reference to `__rethrow'
> 
> 
> _______the makefile_________
> main: main.o Firm.o Employee.o Manager.o \
>              Clerk.o Salesperson.o SalesRecord.o
>         ld -o firm main.o Firm.o Employee.o Manager.o \
>              Clerk.o Salesperson.o SalesRecord.o
> 
> myCompany.o: main.C
>         g++ -c main.C
> 
> Firm.o: Firm.C
>         g++ -c Firm.C
> 
> Employee.o: Employee.C
>         g++ -c Employee.C
> 
> Manager.o: Manager.C
>         g++ -c Manager.C
> 
> Clerk.o: Clerk.C
>         g++ -c Clerk.C
> 
> Salesperson.o: Salesperson.C
>         g++ -c Salesperson.C
> 
> SalesRecord.o: SalesRecord.C
>         g++ -c SalesRecord.C
> 
> __________main.C_______
> 
> /************************************************
>  *
>  *      main is a client to test the Firm
>  *      class.
>  *
>  ***********************************************/
> 
> #include "Firm.h"
> #include "Employee.h"
> #include "Manager.h"
> 
> int main(void)
> {
>         Firm andCo = Firm();
>         Manager smith = Manager("Smith",1, 350000);
> 
>         andCo.add((smith));
>         return 0;
> }//main
> ~
> ~
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming

-- 
laurel at sdf.lonestar.org
http://dreadnought.gorgorg.org


More information about the Programming mailing list