Oct 22, 2011 at 6:54pm UTC
This is my makefile:
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Makefile for Unix & Linux Systems #
# using a GNU C++ compiler #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# compiler flags
# -g --Enable debugging
# -Wall --Turn on all warnings
# -D_USE_FIXED_PROTOTYPES_
# --Force the compiler to use the correct headers
# -ansi --Don't use GNU ext; do use ansi standard.
CXX = g++
CXXFLAGS = -O3 -ansi -Wall
DEBUGFLAGS = -g -ansi -Wall
#Link command:
CalcArea: main.o Circle.o Rectangle.o
$(CXX) -o main.o Circle.o Rectangle.o -o CalcArea
#Compilation commands:
main.o: main.cpp
$(CXX) -c main.cpp -o main.o
Circle.o: Circle.cpp
$(CXX) -c Circle.cpp -o Circle.o
Rectangle.o: Rectangle.cpp
$(CXX) -c Rectangle.cpp -o Rectangle.o
#make clean
clean:
rm -f *.o
Here is a list of the files in the dir:
build CalcArea.save Circle.cpp Circle.h dist main.cpp makefile nbproject Rectangle.cpp Rectangle.h
Here is the error message I am getting:
matthewmpp@anthonyrogers:/usr/Data/Notes/LAMP/Programming/Programs/NetBeansProjects/cpp/CppEO/CalcArea$ make
g++ -c main.cpp -o main.o
g++ -c Circle.cpp -o Circle.o
g++ -c Rectangle.cpp -o Rectangle.o
g++ -o main.o Circle.o Rectangle.o -o CalcArea
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [CalcArea] Error 1
Question: what is "undefined reference to `main'", and how do I fix it.
Thanks in advance for your time and any help on fixing this problem.
Oct 22, 2011 at 7:28pm UTC
That worked perfectly. Thanks very much for your help!