Search code examples
cwindowscodeblocks

How to configure codeblocks?


Why doesn't codeblock find a compiler? I previously tried to install codeblocks(without the mingw setup) into my c: and tried to configure cygwin for it and since I was unsuccessful, I completely uninstalled codeblocks and downloaded the codeblocks with the mingw setup and installed it on my E:, which I thought would have been preconfigured, but the settings from the older one remained:

enter image description here
I had downloaded the mingw setup and installed it on my E: : enter image description here

Since I had the cygwin gcc as the selected compiler, but the site mentioned that the mingw setup had gcc/g++ compiler and debugger, I(thought) I would have to select one from the list but there were many, so I just selected one:

enter image description here
But the compiler always produces an error message:
enter image description here
If the compiler was included within the installer, shouldn't it had configured the path itself? How do I configure codeblocks so that I can start compiling c codes?


Solution

  • If the codeblocks installer failed to setup mingw for you, here's how you can manually add it. In the global compiler settings dialog that you're showing above:

    • Select "GNU GCC Compiler" (it should be the very first option).
    • Select the "Toolchain executables" tab
    • Try hitting the autodetect button. That may or may not work if you have multiple versions of mingw/tdm-gcc on your computer.
    • If it doesn't work:
      • hit the "..." button and manually choose the root folder of the mingw version you want to use. (It's the folder that contains the bin, include, and lib subfolders). Call that folder MINGWROOT.
      • select the "Search directories" tab, and then select the "Compiler" subtab. Hit the add button and enter MINGWROOT\include
      • select the "Linker" subtab, hit the add button and enter MINGWROOT\lib
      • select the "Resource compiler" subtab, hit the add button and enter MINGWROOT\include

    Now whenever you start a new project, when you get to the wizard screen that says something like "Please select the compiler to use...", select "GNU GCC Compiler" (again it should be the first option).