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?
phoffricConnect With a Mentor Commented:
>> 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.
Peter HutchisonConnect With a Mentor Senior 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 👽Connect With a Mentor 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"
naseeamAuthor Commented:
Also, thank for fixing my bug in including a header file.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.