First you will need to install the necessary packages to build Code::Blocks
I am going to use the terminal and aptitude for this tutorial. Aptitude is already installed by default on Ubuntu 6.06. Assuming you are using the default Ubuntu 6.06 with the Gnome desktop environment, you can open a terminal window by going to the Applications menu at the top left of the desktop screen and then going to the Accessories menu. The first time you use the sudo command you will be prompted for your password. This is your regular user password, not some special root password. The sudo command won't ask you again for a password for a period of about 15 minutes or so, at which time it will prompt you again for your password the next time it needs it. You will probably want to make sure you have the extra repositories enabled in your sources.list file. I suggest before using apt-get, aptitude or synaptic to install any software you update your repository information. Now, open a terminal window and enter the following at the prompt:
sudo aptitude update
When the update finishes successfully, install the necessary packages to build the software:
sudo aptitude install build-essential
sudo aptitude install automake1.9
sudo aptitude install libtool
sudo aptitude install fakeroot
sudo aptitude install debhelper
sudo aptitude install libgtk2.0-dev
sudo aptitude install libwxgtk2.6-0
sudo aptitude install libwxgtk2.6-dev
sudo aptitude install wx2.6-headers
sudo aptitude install wx-common
sudo aptitude install zip
sudo aptitiude install subversion
You can actually use one sudo aptitude install command and just list all the packages on one line separated by a space if you want. I used the way above to make it easier to read. You should now have the needed software to start to build Code::Blocks!
Create a build directory and download the svn files
Now make a new directory for building our version of Code::Blocks. After that we want to move into that directory and download the svn files to it. From the terminal window enter the following commands at the prompt:
mkdir CB_build
cd CB_build
svn checkout snv://svn.berlios.de/codeblocks/trunk
The files should start downloading after a slight delay. There are quite a few, so it may take a few minutes for the download to complete. Once the files are downloaded you are ready to start building Code::Blocks from the svn files.
Build Code::Blocks from the svn files
We now need to move into the sub-directory that was created called trunk and start to build our program. From the terminal window enter the following commands at the prompt:
cd trunk
./bootstrap
There is a period and a forward slash in front of the word bootstrap with no spaces. This command sets up the configure script and it's dependencies. Bootstrap will give you a message suggesting you add the contents of /usr/share/aclocal/libtool.m4 to aclocal.m4. Although when I checked there was virtually no difference in the files.
Now at this point I'll show you two different methods of building Code::Blocks. First I will show you how to build it from source and install it directly into your computer. Personally, I feel this is the best method to use because it compiles the program specifically for your machine. The second method I will show you how to build a .deb package that can be installed on other machines too. This method produces a more generic binary file so that it can run on many different types of machines.
Build and install Code::Blocks using ./configure, make & make install method
Building Code::Blocks from source and installing it is fairly easy. Three simple command lines and it's done. First run the configure command:
./configure --enable-contrib
Again there is a period and a forward slash in front of the word configure. The configure command will produce a bunch of text scrolling in the terminal window. This is normal and will take a few minutes. If there are errors they will be listed and configure will abort. If configure completes with no errors then you're ready to make your program. Enter the next command:
make
Pretty simple huh? Well, at this point go get yourself something to drink or eat because this will take a little while to run. It takes approximately a half an hour on my computer. Again, if there are any serious errors then make will abort and produce an error message. Once you are returned to the command prompt your are ready to install Code::Blocks. Enter the next command at the prompt:
sudo make install
This command will now install the various files for Code::Blocks on your computer. After the process finishes you can run Code::Blocks by entering the word codeblocks at the command prompt. However, if you are like me you like to have a nice icon somewhere to click on. Well, that's easily fixed by doing the following:
sudo cp /usr/local/share/applications/codeblocks.desktop /usr/share/applications/
The icon for Code::Blocks should be listed in the Applications menu under Programming. If not, you can logout and back in or enter the command below to restart the Gnome panels:
killall gnome-panel
Now comes the real test. Start Code::Blocks and see if everything runs alright. If so, congratulations!
Just some extra information that you should know. You probably do not want to delete the CB_build directory. It will give you the ability to uninstall Code::Blocks in a nice easy way. To uninstall Code::Blocks you will open a terminal window and use the cd command to move inside the /CB_build/trunk directory. From there you would enter the following:
sudo make uninstall
If you decide to build a newer revision of Code::Blocks you will want to uninstall your current version first. That is why it is a good idea to keep CB_build around. After you uninstall Code::Blocks AND BEFORE you build a newer version you will want to run make clean by entering this at the prompt:
sudo make clean
This will clean up the directory to a point where you can safely run the ./configure command again. So to update your program you would run the steps above from the point where you enter the trunk directory. You do not have to run ./bootstrap again unless you completely delete everything and want to start over. Just skip that step and go to ./configure and follow the rest of the steps from there. If you get errors telling you permission denied when trying to build an updated version, you will want to change the permissions of the CB_build folder so that your username owns it again. You can do this by doing the following:
cd
sudo chown -R yourusername:yourusername CB_build
cd CB_build/trunk
This should fix the problem and you can continue with building the program.
Building and installing Code::Blocks using the dpkg-buildpackage method
Building a .deb package for Code::Blocks from svn is very simple. Once you run the ./bootstrap command you simply enter the following:
dpkg-buildpackage -D -rfakeroot -b -us -uc
The dpkg-buildpackage command will take some time to run. Again, you will see a bunch of text scrolling through the terminal window. Afterwards, it will return you to the command prompt. If errors are encountered the process will abort. dpkg-buildpackage will go through the same steps above of ./configure and make in one easy step. Afterwards you should have a new .deb file of Code::Blocks. To verify that enter the following at the prompt:
cd ~/CB_build
ls
When you run the ls command (that's LS in lower case) you should see a file called codeblocks_1.0svn_i386.deb. If you do, you successfully created a .deb package for Code::Blocks! Now you can go ahead and install your newly created .deb file.
sudo dpkg -i codeblocks_1.0svn_i386.deb
That's it! You should now have a working version of Code::Blocks installed on your computer. To uninstall the package enter the folowing:
sudo aptitude remove codeblocks
You will want to follow the same advice as mentioned at the end of the ./configure-make section. Run sudo make clean before updating your svn files. If you have problems with permissions run the chown command.
Now that you can build and install Code::Blocks you are ready to start coding your projects.
Happy coding!