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 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:

 

image

 

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

 

image

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).

 

image

Renaming a Project

To rename a project, select Project->Rename… The workspace is automatically saved.

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.

 

image

 

 

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:

image

“Reparsing” a Project

CodeBlocks automatically analyzes your project to support code browsing features. Once in a while, especially after you have extensively modified a project by adding and removing files, some of the internal code browsing structures may not be updated correctly. If code browsing does not work, try invoking Project->Reparse current project to see if it fixes the issue.