Makefile Visual Studio Code



VS Code C/C Makefile Project. This extension is generating a simple C/C project structure together with a Makefile which fits almost 99% of all small project's needs. Tip: Just initialize the project in the current working directory with Ctrl+Shift+P on a Windows/Linux or CMD+Shift+P on a Mac and choose C/C Make: INIT Project. Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform. Simple Makefile creator extension for VSCode. Right-click on a folder and click on Create Makefile. You will be ask for the main target name (main by default). Extension Settings. Go to the extension setting to modify flags. Add checkbox for libasan using. Initial release of makefile-creator.

  1. Makefile Visual Studio Code
  2. Visual Studio Code Makefile Tab
  3. Makefile Extension Visual Studio Code
Vs code run makefile

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:MinGWbin in your environment path.
    • Copy C:MinGWbinmingw32-make.exe to C:MinGWbinmake.exe

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

Makefile Visual Studio Code

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.

Visual Studio Code Makefile Tab

  • 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

Makefile Extension Visual Studio Code

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