Introduction: How to Compile C and C++ Projects on Windows

Picture of How to Compile C and C++ Projects on Windows

Most people have written great code in C and C++ on Windows. However, the problem arises when they need to compile it. This Instructable will show two options for compiling these projects.

Step 1: Compiling With Your IDE

Picture of Compiling With Your IDE

Most programmers use an IDE (Integrated Development Environement) when developing applications. Most IDEs come with a compiler built in, or ask you to install a Developer Toolkit so the IDE can use the toolkit's compiler.

In the picture above I am using Visual Studio 2013 (Community Edition). On your IDE, it may be placed somewhere else, or not there at all.

Step 2: Using MinGW

Picture of Using MinGW

Doing a quick Google search of MinGW will lead you to it's SourceForge page. Download mingw-get.exe and run it. It will tell you to configure a few things, then it will show you an installation manager. First, check mingw-base, then click All Packages, then MinGW, and then MinGW base system. Mark for installation (right-click on the package name and click Mark for Installation) the following packages : mingw-gcc, mingw-gcc-core, gcc, gcc-core, mingw-gcc-g++, and gcc-g++. (If you can't find gcc, gcc-core, or gcc-g++, use the ones with mingw on them. This also applies if you can't find the mingw ones.)

After installation, open up your Command Prompt. Then navigate to where you installed it. Drag your code file into the directory where you installed MinGW. Finally, run g++ (for C++) or gcc (for C) followed by the code name. It should then generate a executable file simply called a. That is your compiled code.

Step 3: Done!

Hopefully with one of those options you have successfully compiled your code. See you next Instructable!

Comments

tomatoskins (author)2015-07-30

Great info! Do you use the same compiler for both C and C++?

@tomatoskins No, for C you use the GCC compiler. That is run from Command Prompt using the code "gcc <filename> -o <filename>.exe"

Same code for G++ (c++ compiler) but replace gcc with G++

About This Instructable

789views

13favorites

License:

Bio: My name is Sahib. I like to program in many languages. Most prominently in Java and C++, however I sometimes do projects in C, and ... More »
More by InitializeSahib:Understanding the Linux File Hierarchy StandardWelcome to Autotools: a Portability Solution for Linux SystemsHow To Compile C and C++ Projects on Windows
Add instructable to: