I am trying to compile my classes but I am getting the following error
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [try] Error 1
However, I do include a main function, in a class I call Hash.cpp. Here is the makefile:
C++ = g++
CFLAGS = -c -g
all: hash
hash: Hash.o ML_hash.o
$(C++) -o hash Hash.o ML_hash.o
%.o: %.cpp
$(C++) $(CFLAGS) $*.cpp
When I call "make clean" and "make" though, the output executable "hash" will still be generated. If Hash.cpp is listed in the makefile and contains a main function, why I am getting the error below?
EDIT:
Sorry....I meant to say main function. And here is the main class:
#include "HashNode.h"
#include "MLH_back1.h"
#include <iostream>
using std::cout;
using std::endl;
int main()
{
doStuff();
}
I'm sorry if I didn't post enough code. Usually when I ask questions I try to post where I think the problem is occurring, so just relevant information is listed instead of all of my classes. By saying "I have a main function" I meant to say that yes I did write a main function in a class called Hash.cpp. I was just asking to try to get a conceptual understanding of why this error would occur when I have a main function. I have looked at other questions so I'm not trying to duplicate. I didn't realize people would downvote this so much...