How to compile multiple c++ files?

Hello, I'm using Mingw development environment.  Minimalistic gnu for windows.
I know the compile command is g++.  But how do I compile and run multiple files?

Files are attached.

This is not homework.  I am not in school.

Thank you!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peter HutchisonSenior Network Systems SpecialistCommented:
What you need is a makefile and then compile it with the 'make' command. For example, a makefile would look something like this:

objects = Gradebook.o Gradebook-test.o

edit : $(objects)
             cc -o edit $(objects)

GradeBook.o : Gradebook.h
GradeBook-test.o : Gradebook.h

 .PHONY : clean
     clean :
             rm edit $(objects)

More info at
käµfm³d 👽Commented:
Yeah, a MAKEFILE makes compiling a lot simpler. You can, though, pass each file as an argument to c++.exe:

c++ GradeBook.cpp GradeBook.h GradeBook-test.cpp

I will tell you that you need to correct your #include statement. Standard includes are imported by using the angle brackets ( <library_header> ); but your own libraries need to be surrounded with quotation marks.


#include "GradeBook.h"
>> c++ GradeBook.cpp GradeBook.h GradeBook-test.cpp

but leave out the middle header file:
c++ GradeBook.cpp  GradeBook-test.cpp

this assumes that your header file is in the same folder as your .cpp files.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
naseeamAuthor Commented:
Also, thank for fixing my bug in including a header file.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.