hi,

i have 3 files in different directory

1st under include directory have memoryleak.h file (ie include/memoryleak.h)
2nd under Test0 directory have memoryleak.cpp file (ie Test0/memoryleak.cpp)
3rd under Test1 directory have memory.cpp(ie Test1/memory.cpp)

content of memoryleak.h

class Base{
public:
void display();
};

content of memoryleak.cpp

#include<iostream.h>
#include "../include/memoryleak.h"

void Base:isplay(){
cout<<"Display Base"<<endl;
}

content of memory.cpp

#include<iostream.h>
#include "../include/memoryleak.h"

int main() {
Base *obj = new Base();
return 0;
}



i am compliing all the three in single makefile.

so make file content

CXX := g++
CXXFLAGS := -g -w
OBJDIR := /home/ramamj/TestObj/
VPATH = Test0 Test1 include TestObj

.PHONY: all
all: memory.o memoryleak.o

.PHONY: clean
clean:
rm -f TestObj/*.o

memobj: memory.o memoryleak.o
$(CXX) $(CXXFLAGS) $< -o memobj $(OBJDIR)memory.o $(OBJDIR)memoryleak.o

memory.o: memory.cpp memoryleak.h
$(CXX) $(CXXFLAGS) $< -o $(OBJDIR)memory.o
memoryleak.o: memoryleak.cpp memoryleak.h
$(CXX) $(CXXFLAGS) $< -o $(OBJDIR)memoryleak.o

After compling all the three, I am getting the below error

g++ -g -w Test0/memoryleak.cpp -o /home/ramamj/TestObj/memoryleak.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [memoryleak.o] Error 1

coud you please help on this?

Regards
Jai