I'm having a bit of trouble trying to compile the following simple code in cygwin:
main.cpp:
#include <iostream>
#include "Point.h"
using namespace std;
int main() {
Point a;
return 0;
}
Point.cpp:
#include <iostream>
#include "Point.h"
using namespace std;
Point::Point() {
cout << "Compile test" << endl;
}
Point.h:
#ifndef POINT_H
#define POINT_H
class Point {
public:
Point();
};
#endif
Make file:
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp Point.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=test
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
%.o : %.cpp
$(CC) $(CFLAGS) -c $<
clean:
rm -rf *.o core
When I try to compile main.cpp, I'm getting the following error:
main.o:main.cpp:(.text+0x15): undefined reference to `Point::Point()'
main.o:main.cpp:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Point::Point()'
And when I try to compile Point.cpp, I'm getting:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-2.2.1-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-2.2.1-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
All files are in the same directory. I should also note that the main class compiles perfectly fine if I don't create the point object. Any ideas? Would really appreciate some help, thanks!