Workspace

Workspace in Code::Blocks is a collection of projects. Workspace acts as a container of projects and also maintains project dependencies. So if project 2 is dependent upon project 1, then project 2 will be compiled before compilation of project 1.

Consider the following snippets. Create a static library project named libcalc by navigating to File | New | Project… and select Static library wizard.

Then replace code of project's main.c file with the following code:

int mult(int a, int b)
{
    return (a * b);
}

Next create a console project named App6 and then replace its main.cpp file with the following code:

#include <iostream>

extern "C" int mult(int a, int b);

int main() {
    std::cout << "2 * 3 = " << mult(2, 3);
    return 0;
}

The Management window now shows two projects in one workspace. Workspace has been renamed to App6 in the following screenshot:

Workspace

This workspace can be saved by navigating to File | Save workspace as… menu option. Right-click on the App6 project in project tree and click on the Screenshot menu option. Next click on the Project's dependencies button. The following window will be presented:

Workspace

Click on the Close button to close this window and then the OK button to close Project/target options window. Now App6 is dependent upon libcalc project.

Now navigate to Project | Build options… menu option and add ..libcalclibcalc.a to Link libraries in Linker settings tab.

To compile these two projects navigate to the Build | Build workspace menu option. Code::Blocks will now build App6 taking care of its dependent project.

It is now quite clear that we can use workspace to manage sub-projects in a large project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.254.118