I have a class.h/class.cpp outside my main file. When compiling my main file, I have to do the following:
Code:
g++ -Wall -g -o main main.cpp class.o
Is this normal? Or am I doing something wrong?
In my main I do have #include "class.h" but I still have to put that class.o on the g++ line, otherwise I get tons of errors:
Code:
/tmp/ccbTjMPf.o: In function `Line::draw(Image&)':
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Line.h:53: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/tmp/ccbTjMPf.o: In function `Background::draw(Image&)':
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Background.h:72: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/tmp/ccbTjMPf.o: In function `Circle::draw(Image&)':
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Circle.h:52: undefined reference to `Image::DrawCircle(int, int, int, Vec3f const&)'
/tmp/ccbTjMPf.o: In function `Triangle::draw(Image&)':
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Triangle.h:56: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Triangle.h:57: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Triangle.h:58: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/tmp/ccbTjMPf.o: In function `Quadrilateral::draw(Image&)':
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Quadrilateral.h:61: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Quadrilateral.h:62: undefined reference to `Image::DrawLine(int, int, int, int, Vec3f const&)'
/tmp/ccbTjMPf.o:/fs/home1/student/s/myfolder/cs60/myfolder_proj3/Quadrilateral.h:63: more undefined references to `Image::DrawLine(int, int, int, int, Vec3f const&)' follow
/tmp/ccbTjMPf.o: In function `CPPDraw::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/CPPDraw.h:90: undefined reference to `Image::SavePPM(char const*) const'
/fs/home1/student/s/myfolder/cs60/myfolder_proj3/CPPDraw.h:92: undefined reference to `Image::SaveTGA(char const*) const'
collect2: ld returned 1 exit status