Code::Blocks is a useful IDE that can include compilers for C and C++. In order to use Code::Blocks for C/C++, there are two things to install and one to configure:
1. Download and install the gcc compiler by installing MinGW as described in this article
2. Download and install Code::Blocks from this site. A link to nightly builds is provided in case you want to try a very recent build but read the documentation first. Some versions come with the MinGW compiler and some do not. In this article, we assume you downloaded the version without MinGW.
3. Configure the compiler and build tools in Code::Block
To configure Code::Blocks for MinGW proceed as follows:
1. Launch Code::Blocks and open the Settings->Compiler dialog:
2. Select Compiler menu:
3. Select MinGW64 in the "Select Compiler" input box:
5. Create a C or C++ program (see example) and save with file extension .c or .cpp respectively:
5. Select Build->Build and run menu to compile and build the program:
At this point, you have successfully installed and configured the compiler and IDE. If build fails, some troubleshooting is required.
1. Download and install the gcc compiler by installing MinGW as described in this article
2. Download and install Code::Blocks from this site. A link to nightly builds is provided in case you want to try a very recent build but read the documentation first. Some versions come with the MinGW compiler and some do not. In this article, we assume you downloaded the version without MinGW.
3. Configure the compiler and build tools in Code::Block
How to Configure Code::Blocks
When you install Code::Blocks, it tries to detect the compiler. There is a long list of compilers it can use but our interest is MinGW and Cygwin because they are the most reliable, updated open source C/C++ compilers for Windows. For Linux, gcc is a core part of the OS and is installed by default.To configure Code::Blocks for MinGW proceed as follows:
1. Launch Code::Blocks and open the Settings->Compiler dialog:
3. Select MinGW64 in the "Select Compiler" input box:
4. Select Toolchain tab and use the input boxes labelled 1, 2, and 3 to select the MinGW bin folder path (c:\MinGW-w64\mingw64\bin in this case) and the various compiler and build tools from this /bin folder as shown below. Be careful to select the correct tools:
5. Create a C or C++ program (see example) and save with file extension .c or .cpp respectively:
This particular program gives the following (successful) output:
At this point, you have successfully installed and configured the compiler and IDE. If build fails, some troubleshooting is required.
Comments
Post a Comment