g_rmz
g_rmz

Reputation: 741

Compiling a C++ Project with Cygwin

I've made a little project to get experience with OOP in C++, i'm on Windows (with Cygwin). The classes are point.h (the base class), point.cpp (implementation of point.h), coloredPoint.h (the derivated class), coloredPoint.cpp (implementation of the derivated class) and main.cpp (whic creates a point object and a coloredPoint object). To run the main I type

g++ point.cpp coloredPoint.cpp main.cpp -o main

and all goes well! I know that this may could sound stupid...but is this the right way to do it?

Upvotes: 1

Views: 1086

Answers (1)

Bruce Dean
Bruce Dean

Reputation: 2828

For C++ you will want to replace gcc with g++ or add -lstdc++ (if you want to use the std c++ library) to your gcc command line:

gcc point.cpp coloredPoint.cpp main.cpp -o main -lstdc++

or

g++ point.cpp coloredPoint.cpp main.cpp -o main

which links the std c++ library with your compiled code. With g++ you do not have to add this step.

Upvotes: 2

Related Questions