Other Project Tasks

Opening a Project

Use File->Open… or File->Recent Projects… to open an existing project. (File->Open… is used for opening many different types of files)

Adding Include Files to a Project

If you use something like the ST CubeMX to create a project, or if you start with existing code from a third party, it is common that the code may reference many header files. While it is not actually required to add the include files to the project file list (as only C or C++ source files are needed in the project per se), it is recommended to add them in order to take advantage of the IDE’s autosaving feature or the code browsing features. Invoke Project->Add files recursively… and browse to the include folder:




Follow the instructions to add the files. They will appear in the “Headers” virtual folder on the project file list display pane:



Inter-project Dependencies In a Workspace

If you use a workspace to organize related projects, you may also specify dependencies among the projects in a workspace:


  1. Invoke Project->Properties, switch to the Project settings tab (if needed).
  2. Click on Project’s dependencies on lower right.
  3. A project may depend on any number of other projects. You may set up serial dependencies where project A depends on project B, and project B is dependent on project C. CodeBlocks is smart enough to disallow circular dependency chains (e.g.: project A → project B → project C → project A).



Cloning a Project

With the complexity of the header files and build options, often the best way to create a new project is to base it off of an existing working project. Then you can modify, add, and remove files as needed for the new project.


To do this, invoke File->Clone project… and follow the instructions to clone a project. You can specify the new project’s location and its (new) name. If there is a currently active project in the IDE, its project file is automatically set as the default source project. You may change the source project as you wish.



Making a Project Into a Template

To make a copy of a project, for example, if you are creating another program in which you want to reuse the code from an existing project, the easiest is to first save the project as a template via File->Save as template… You will be prompted to give the template a title (name):




Then, you can create another project based on that template via File->New->project…, click on “User templates”:




Once you select a template name, click Go, and follow the instructions. To remove a template, follow the note in the dialog box as shown above.

Saving a Project as an Archive

This feature allows you to save the entire project as an archive file, e.g. a zip archive file. This is useful if you need to send the project to another person. You will need to install a GNU-compatible tar program for this to operate: