User forums > Using Code::Blocks

Conceptual help with "workspace"

(1/2) > >>

grreg:
Hi, I'm just getting started with some programming tutorials and so far I'm thrilled with how easy it was to install code::blocks and start writing beginner code. I understand source files and object files and it seems clear that "projects" are collections of related source and object files, but I'm confused by this "workspace" idea. Can someone give a conceptual overview of where it fits into the organizing structure I'm looking at? I've lost some of the my first few attempts because it isn't clear to me how to properly save the stuff I've done in a way that will keep it organized. I'd really appreciate any help.
-Greg

Game_Ender:
There are three main concepts here, Targets, Project and Workspaces.  Every project has multiple targets, every workspace has multiple projects.  Each target represents a single output, usually an executable or library file of some sort.  Most things you do as a beginner will involve just one project.  That one project my have a targets for a support library, main program and test suite.  These targets will each be dependent on the source files of your project and will be rebuilt when any of there dependent files change.

Now that you kind of get what project you can understand workspaces better.  They are just a collection of the projects you are currently working on.  In that workspace you can only have on active project at a time.  There is a default workspace that codeblocks will maintain, but you can create you own if you are working on a very large system that has many subprojects.  Ogre for example has workspace containing projects for its main library, platform support libraries, demos and tools.  You can tell codeblocks to build the entire workspace.  You can also tell codeblocks that certain projects are dependent on other projects.  So if you were working in our Ogre workspace and update the OgreMain project, all of the demo projects would be rebuilt because they were set to be dependent on the OgreMain project.

grreg:
Hi Game_Ender,
thanks for the overview, I think I understand the idea. I seem to be having trouble with the execution. I created my first project using the "file/new project" menu item. It brings up a dialog for choosing what I believe is the target?(console application, dynamic link libary, ogre apllication, etc...) since I'm starting with the simple "hello world" thing I chose console application. Now I have a project called "console application" (actually I have a few projects called that because I can't figure out how to give them different names) which contains my "hello world" source file which is called main. So when the next chapter of my book wants me to write a new program, I should create a new project within the same workspace, right? They will all be console applications at this stage and I may as well keep all my attempts in one workspace. I've tried using "save project as..." to make a copy of what I was doing so I could modify it while retaining my previous work. But the project file that results won't open. I've looked for documentation so I wouldn't have to ask so many questions, but either I failed to find it or there isn't much.
-Greg

Game_Ender:
Those choices you see are project templates/wizards.  They help you get started by adjusting the starting settings of the projects they generate.  This makes it easier include the proper libraries, have proper output file type, etc.  So in short, they just configure the project, they aren't targets.

The "Save Project As..." and "Save Workspace As..." options don't create copy the entire contents of the project, they only copy the project file it self, or the workspace file itself.  It is important to remember that CB starts up with its default workspace so if you want a special to create it (as you have already figured out).  It is also important to note that a workspace is just an xml file that stores the relative file system path to each of its projects and some other information. Here is how I would layout my work:


--- Code: ---My_Files/
    My_Work_1/
        work.workspace
        Console_Proj_1/
        Console_Proj_2/
    My_Work_2/
        work.workspace
        Console_Proj_1/
        Console_Proj_2/
        New_Console_Proj/

--- End code ---

So the "My_Work_1" directory is manually created by you to keep your work in.  Then you tell CB to create you new projects in the "My_Files/My_Work_1" folder.  After you have created more projects and want to save you workspace just use "Save Workspace As..." and save the workspace in the "My_Work_1" folder.  Now if you want to keep this set group of work and make some major changes you must manually copy the "My_Work_1" folder.  After this if you want to work in your first workspace just open up "My_Work_1/work.workspace" or "My_Work_2/work.workspace" for you new one. 

Game_Ender:
You seem a little new to development, what you are trying to do is better accomplished with a Source Control System.  Once you feel more experience with how compilers, linking and Code::Blocks works see this informative howto and once you get that, check out information about SVN the source control system CB developers use.

Source Control in a nut shell:  It keeps track of changes to your files and folders in a central repository.  This lets you go back to any version of those files or compare you current versions.

Navigation

[0] Message Index

[#] Next page

Go to full version