-
Beginning C++ 3, Setting up your Development Tree
Posted on April 19th, 2009 No commentsSetting up your Development Tree
Your development tree is basically the directory structure that holds your source code, it can be as big and as elaborate as you like however it should have only one root.
Before you rush in and start programming, it’s a good idea to think about where your development tree should be. I believe it is best to put your development tree in a user readable/writable part of your directory hierarchy. The most obvious place to put it, is under the “My Documents” folder for your user. If you put it anywhere else, you need to remember you will need to adjust the permissions of the tree so that all the users who need to use it have access.
The form your development tree should take is a vast topic, with many variations possible. Here are a few simple guidelines to follow while working on your development tree.
Has only one root
Your development tree, doesn’t depend on any code outside of it.
Exceptions include operating system and compiler header files and runtime libraries.Standalone and movable
It is a good idea to make your development tree standalone. So you should be able to copy it anywhere else on your filesystem and you should still be able to build all your projects without adjusting any settings.Generally Contains only Original Source and 3rd Party Libraries
This is more of a guideline than a rule. You need to decide where your source stops and your build environment and platform starts.
This is often determined by the capabilities of your source control system. You could check everything in, including your 3rd Party binaries, your compiler, your operating system and even a Virtual Machine image of the build environment. This would truly make your development tree standalone. But also very big and possibly difficult to work with depending on your source control system.Normally your development tree would contain only original and 3rd party source code and resources. Anything else that your development tree specifically depends on, for instance compilers and operating systems, should be clearly defined and backed up.
Keep your 3rd Party libraries in your development tree
This is more of a convenience than an absolute necessity. Having your 3rd party libraries outside of your development tree makes it harder to move the tree to a different computer, where you’ll need to independently install the libraries on that computer. Again this depends on your source control system (How large a tree it can handle) and your colleagues preferences, you’ll probably have to find a middle ground. However I just put them in my development tree until there is a compelling reason not to.Creating your first Development Tree
Here is the process for starting a new development tree.
Log in as the normal user and start up Visual Studio.
Select File->New->Project
Select Visual C++ -> Win32 -> Win32 Console Application
Call your new project “HelloWorld”
Set your location to “My Documents”
Set your Solution Name to “MyDevTree” and make sure “Create directory for solution” is ticked.It is not obvious from this dialog box, but it will create a directory hierarchy under your My Documents folder, with MyDevTree as the root. Your project will be located in: My DocumentsMyDevTreeHelloWorld
Click Okay
Click Next, You’ll see:Turn precompiled headers off. They are only necessary for larger projects, and will be an unnecessary distraction.
Click Next and your project should be setup. Your screen should now look like this:
Your development tree will look like this:
The root of your developer tree is now “MyDevTree” inside the “My Documents” directory. You have one project inside the devtree called HelloWorld. You also have 3 files inside MyDevTree. MyDevTree.sln is the Solution file that Visual Studio uses to manage multiple projects it must be checked into source control. The .ncb file is where Visual Studio caches it’s Intellisense data, it may be deleted at any time, it is not usually backed up or checked into source control. MyDevTree.suo is where Visual Studio keeps the user settings for the Solution, you may delete this with no harm to the solution, it is not usually backed up or checked into source control.
The contents of the HelloWorld project looks like this:
The vcproj file and *.cpp and *.h file are the actual program to be compiled.
Thats it for now
Next up, we need to talk about the structure of the program, running it, how we can modify it to do interesting things. I also need to talk about Source Control Systems. I’m not sure which I’ll talk about first, so it’ll be a surprise.
Happy Programming
Leave a reply









