For my computer graphics course, I have to submit all my projects using C++, compiled using g++ and a Makefile.

If you don’t know what a Makefile is, it’s basically a list of steps/depencies to get to the final product. For example, to end up with DogSimulator.exe, you will need to run g++ on DogSimulator.o and Dog.o (compiled objects). And the prerequisites to DogSimulator.o and Dog.o are DogSimulator.cpp and Dog.cpp respectively.

It’s not too hard in the terminal, because once you have all your files in the terminal, you just type “make” and the magic ensues. But I’m a snob for my Visual Studio IDE, so I am going to set it up there. Haha.

Step 1 – Install Software

  • Visual Studio (http://www.visualstudio.com)

    • We need an IDE, and the whole reason for this post 🙂
    • Make sure to select C++ when prompted during install
  • MinGW (http://www.mingw.org)

    • Nice package that includes G++ and Make
    • Basic Setup: mingw32-gcc-g++
    • All Packages: mingw32-make (bin) and mingw32-pthreads-w32 (dev)
    • Make sure to include C:\MinGW\bin in your environment path.
    • Copy C:\MinGW\bin\mingw32-make.exe to C:\MinGW\bin\make.exe

Step 2- Create a Visual Studio C++ Makefile Project

Now we should be able to create a new C++ Makefile project. I’ll list two examples below. Regardless of which one you use, use the following settings when creating the project.

  • Build command line: make
  • Clean commands: make clean
  • Rebuild command line: make clean all

Step 3 – Simple Hello World Example!

We will create two files: main.cpp and Makefile

 

Just click the Play Button (ie Local Windows Debugger). Hello World should come up!