PDF download Download Article PDF download Download Article

Code::Blocks is a great tool if you're learning to code because it compiles data in C, C++, and Fortran, and it works on Windows, MacOS, and Linux. We'll show you how to set it up, then we'll walk you through creating a basic "Hello World" C program!

Part 1
Part 1 of 4:

Downloading Code::Blocks

PDF download Download Article
  1. :Blocks from their official site . Navigate to the download page. Under the Windows section, select the "mingw-setup" variant; this is an all-in-one installer that includes all necessary tools. Select either download link to continue.
  2. After clicking a download link, a window will appear, prompting you to select a location to save the installer file. First, choose a save location, then click "Save" to continue.
  3. Advertisement
Part 2
Part 2 of 4:

Installing Code::Blocks

PDF download Download Article
  1. After the download completes, start the installer. The installer will be located in the location specified when it was downloaded.
  2. After launching the installer, the setup wizard will appear on screen. To continue, click the "Next" button.
  3. Read the end user license agreement. After reading, click "I Agree" if you agree to the terms and want to install the software.
  4. Make sure that "Full" installation is selected from the drop down menu at the top; this includes all necessary software components. After this is done, click "Next" to continue.
  5. By default, Code::Blocks will install under C:\Program Files (x86)\CodeBlocks\. If you want to use this, click "Install", otherwise, use the "Browse" button to select a custom install path before starting install.
  6. The installation will take several minutes to complete and will show its progress in the window.
  7. When prompted, do not run Code::Blocks. First, complete install wizard.This is done by clicking the "Next" button on the installer screen, then clicking "Finish" on the completion page.
  8. Advertisement
Part 3
Part 3 of 4:

Setting Up Your C File

PDF download Download Article
  1. To launch the program, double click the Code::Blocks icon the installer placed on your desktop. If you do not have a desktop shortcut, the program can be found under Start--> All Programs ---> Code::Blocks --> CodeBlocks.exe
  2. If prompted, accept GNU GCC Compiler as the default. To do this, click the entry for GNU GCC Compiler, then click "Set as Default". To continue, click "OK".
  3. If prompted, select the option to associate Code::Blocks with C and C++ file types, then click "OK". This will allow you to open these types of files in Code::Blocks by default.
  4. On the main page, select the link next to the folder icon. This will open a new window in which you will set up your project.
  5. On the "New from Template" window, select the "Files" heading on the left side of the window. Then, select the "C/C++ Source" option. Click "Go" to continue.
  6. Use the wizard to create and configure your C file. To continue, click "Next".
  7. Select the option to create a "C" file. Once selected, click the "Next" button to continue.
  8. Click the "..." button on the setup menu to open the explorer window to allow you to create your C file.
  9. First, browse to the location you wish to save your C file in (it is recommended that you make a separate folder for each project). Next, choose a name for your C file. Finally, click "Save" to save your file with the name and location specified.
  10. To confirm creation of your C file, click "Finish".
  11. Advertisement
Part 4
Part 4 of 4:

Creating a Simple C Program

PDF download Download Article
  1. To create your "Hello World" program, copy the code below into Code::Blocks: #include <stdio.h>#include <stdlib.h>int main(){printf("Hello World.\n");return 0;}
  2. Click the "Build and Run" icon to run your program. This function compiles then runs your program in one convenient step.
  3. After running, a terminal window will pop up with the message "Hello World." The process should return 0. If a different value appears, there may be an issue with your program. The execution time will vary based on the speed of your computer.
  4. Advertisement

Community Q&A

Search
Add New Question
  • Question
    My program is not building. What do I do?
    Community Answer
    Refresh it, if that doesn't work, then turn off and then turn on your device. Finally, if that does not work, you should delete and reinstall it.
  • Question
    I downloaded Code::Blocks, but entered the wrong settings. Now I know the correct ones, but even after uninstalling and downloading it again it does not ask me for the settings, and stays like it was before. What can I do?
    joeypencil 881
    Community Answer
    When uninstalling Code::Blocks, there is a prompt which asks you if you want to retain your settings post-uninstallation. Decline this, allowing it to remove the previous settings, then install Code::Blocks again.
  • Question
    What do I do if I'm trying to use Code::Blocks, but it's saying I don't have a GNU compiler?
    Community Answer
    Try uninstalling and reinstalling Code::Blocks again, it should show up when you initially download the program.
Ask a Question
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      Things You'll Need

      • Computer running Windows XP, Vista, 7, 8, or 10
      • Access to a Windows account with the ability to install software (administrator)
      • A stable internet connection

      Expert Interview

      Thanks for reading our article! If you’d like to learn more about programming, check out our in-depth interview with Tyrone Showers .

      References

      1. Code::Blocks Download Page: http://codeblocks.org/downloads/26
      2. Code::Blocks Wiki: http://wiki.codeblocks.org/index.php/Main_Page
      3. Textbook: The C Programming Language, Second Edition. Brian Kernighan, Dennis Ritchie ISBN-13: 978-0131103627, ISBN-10: 0131103628

      About This Article

      Thanks to all authors for creating a page that has been read 82,329 times.

      Is this article up to date?

      Advertisement