Code::Blocks FAQ

Chris Riesbeck
Last updated: July 3, 2009

Code::Blocks is a free integrated development environment (IDE) for C and C++ on Windows, Linux and MacOS X. For the most part, it works quite well on these platforms, but some parts can be confusing. Hence, this Frequently Asked Questions file.


Code::Blocks says "invalid compiler. Skipping..."

Does gcc --version work in a Cygwin shell window?

Is Cygwin GCC selected as your default compiler in Settings | Compiler and Debugger?

Is Cygwin GCC selected as the compiler to use in the Project Build Options?

If the above are true, then the problem is probably that the gcc.exe file in the Cygwin bin directory is a Unix-style shortcut that Code::Blocks doesn't know how to use.

Now go back to Code::Blocks.

You should be good to go now.


Code::Blocks keeps saying "It seems this project has not been built yet" when I try to compile and run.

Is the title of the project in Project Properties exactly the same as the value assigned to PROJ in your Makefile?

If not, your Makefile is making a .exe with one name and Code::Blocks is looking for a different name. Fix your Makefile to agree with the title.


Code::Blocks says "undefined reference to `_WinMain@16'" when I try to compile and run.

This means that none of the files in your project defines a main() function. The most common cause of this is leaving out the .cpp file with main() in your Makefile. Typically in this course that will be your test file.


What's the difference between a workspace, project and application?

An application is a runnable program. Most applications are built from multiple source files. Code::Blocks and other IDEs keep track of the files and compiler settings need to build an application with a project file. In Code::Blocks, these files have the extension cbp.

Some IDEs, including Code::Blocks, let you collect projects together into a workspace, where you can easily switch between projects, define a common set of editor preferences, and so on. In Code::Blocks, these files have the extension workspace.


Why isn't my project in my workspace?

If you started the Code::Blocks application directly, and selected one of your projects in the Recent projects list, or you double-clicked a project file, then a new workspace is started with just that project.

The better way to start Code::Projects is by double-clicking your workspace file. Then you'll get the workspace you had before with all the projects in it. Don't forget to activate your project!


Why am I getting a ton of errors about CppUnit?

A number of things could be wrong. Check the following:


Why is Code::Blocks ignoring changes I make to code, settings, ...?

Make sure your project is active in the workspace, if you have more than one. The title of the currently active project is shown in bold face in the workspace window. Any changes to Settings or Build options affect the currently active project only.

If some other project is active, you can easily end up changing settings and files for the wrong project.

To change the currently active project, right click (control-click in MacOS X) on the title of the desired project and select Activate project from the popup menu.

If multiple projects in a workspace confuse you, you can remove a project from the workspace.


Why don't my header files show up when I add them to my project?

Code::Blocks automatically puts all header (.h) files under the Header "folder" in the workspace window. Even though they're greyed out, they can be opened for editing by double-clicking on them.


How do I remove a project from my workspace?

Right-click (Windows and Linux) or control-click (MacOS X) on the project name in the workspace manager window, and select Close project from the popup menu.

This remove the project from the workspace. It does not delete it from your computer.


How do I add an existing project to my workspace?

Use File | Open... and choose the project.cbp file. The project will be opened and added to your workspace.

Do File | Save Everything to save this change.


How do I copy a project into a new project?

In Windows, copy the entire project directory and give it a new name. Then follow the instructions for adding a project to the workspace.


Comments? comment icon Let me know!

Valid HTML 4.01 Transitional