代码改变世界

ubuntu上关于Code::Blocks(8.02RC)的安装全记录

2009-08-11 17:12  htc开发  阅读(208)  评论(0编辑  收藏  举报

 Code::Blocks是一个开源的跨平台的C/C++的IDE,和VC++系列的IDE非常类似,这对于从windows下转型到Linux的用户 是一个非常不错的选择。windows下早就安装过了,体验之后非常不错,虽然和vc不能相提并论,但是在linux下面能够使用到这么强大的IDE已经 非常了不起了。那么开始把,本人的系统是ubuntu8.04,几经周折,终于成功完成。

    开始到处google资料,最后尝试N次之后才发现,官方就有CB的安装方法,具体链接在wiki上:

Installing Code::Blocks nightly build on Ubuntu


这个因为是国外网站打开速度可能比较慢,我就替大家贴出来吧:

Installing Code::Blocks nightly build on Ubuntu

From CodeBlocks

Jump to: navigation , search

This is a quick guide to get Code::Blocks up and running on your Ubuntu based Linux distribution. It is also going to make sure you can develop wxWidgets applications on your box as well. Look at the bottom of this guide for a complete command line that will install all the packages in one operation.

First be sure you have the necessary software to compile and debug programs.

1. Install the compiler.

sudo apt-get install build-essential


2. Install the debugger.

sudo apt-get install gdb


You'll need to install wxWidgets to use Codeblocks. Revisions prior to revision 4051 use wxWidgets 2.6 and revisions from 4051 and after use wxWidgets 2.8.4. If you want to install a revision prior to revision 4051, make sure you have your universe and multiverse repositories enabled and install the following packages.

3. Install wxWidgets library. (This package is all that is needed to run any application that uses wxWidgets. ie. Code::Blocks)

sudo apt-get install libwxgtk2.6-0


4. Install the wxWidgets developement packages. (This is used to develop wxWidgets applications of your own.)

sudo apt-get install libwxgtk2.6-dev wx2.6-headers wx-common



(注:上面2个步骤非常重要,缺了gtklib后面的deb包安装就会失败)

5. (OPTIONAL) Install the wxWidgets documentation.

sudo apt-get install wx2.6-doc


(注:在下载wxWidgets系列库的时候其实可以直接使用新立得软件更新包管理器来 搜索wxWidgets字眼,然后从当中的列表中选择最新的库来装.直接选就可以省掉上面一对麻烦的命令,其实上面的几个步骤无非就是完成libgtk库 和wxWidgets相关库的安装,这在新利得上搜索wxWidgets很容易选择。)
To install wxWidgets 2.8.4 you need to be using Ubuntu 6.10 (Edgy Eft) or Ubuntu 7.04 (Feisty Fawn) and you need to add the wxWidget repository to your sources.list. You can install wxWidgets 2.8.4 on Ubuntu 6.06 (Dapper Drake), but the nightly builds are not made to run on Dapper.

1. Backup your current sources.list first for precaution.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2. Open your sources.list in a text editor to edit it.

gksudo gedit /etc/apt/sources.list

3. Add the correct repository for the Ubuntu version you are running to the end of the file. The repository listed below is referenced on the wxWidgets.org download page and appears to be for the stable version.

deb http://apt.tt-solutions.com/ubuntu/
 edgy main

or

deb http://apt.tt-solutions.com/ubuntu/
 feisty main

4. Save and close the file.

5. Add the key for tt-solutions.com.

sudo wget http://www.tt-solutions.com/vz/key.asc



sudo apt-key add key.asc


Alternate wxWidgets repository. Some users of Code::Blocks have received critical errors related to libwxgtk when using the above repository packages. They were able to solve their problems by installing newer packages available from an alternate repository from wxWidgets.org. To use these packages make the following changes to the above directions:

Add deb http://apt.wxwidgets.org/
 edgy-wx main or deb http://apt.wxwidgets.org/
 feisty-wx main to your sources.list.

Download the gpg key using wget http://apt.wxwidgets.org/key.asc and install the same as above.

6. Update your sources.list and run upgrade to make sure everything is up-to-date.

sudo apt-get update
sudo apt-get dist-upgrade

7. Now you're finally ready to install wxWidgets 2.8.4.

sudo apt-get install libwxgtk2.8-0 libwxgtk2.8-dev wx2.8-headers wx-common

8. Set wxWidgets 2.8 as default version for your machine. Select number for the wxgtk2.8 version.

sudo update-alternatives --config wx-config

Now go get the nightly build and install it. All dependencies should now be met.

1. Get the latest nigtly build of Code::Blocks from the nightly builds forum .

2. Install Code::Blocks.

sudo dpkg -i <Name_Of_Daily_Build.deb>

NOTE: Since revision 4281 and after, the nightly builds are made differently. Codeblocks is now packaged into separate Debian packages and the packages are archived together in a tar.gz file.

(编 者注:其实所谓的nightly build版本只是在version4281之前才有效,后来的的版本是不需要下载所谓的nightly&&deb版本,直接到官方网站下载deb包,里 头有6个小包,直接使用后面的dpkg -i *.deb就可以了。这里头千万别被nighlt弄混了,直接无视就是了。)

1. Download the tar.gz file to your computer and extract the files to an empty directory, such as one called temp for example.

tar xvf CB_date-of-build_revision-number
_Ubuntu6.10+7.04_wx2.8.4.tar.gz



(编者注:这里只是解压deb的命令,也可以直接在IDE上右键选择“解压缩到此处。。。”即可)

2. Install all the packages at the same time.

sudo dpkg -i *.deb


(注:大功告成的语句)

The packages can be installed individually, if you prefer not to install everything. The first package to install is libcodeblocks0 followed by the codeblocks package. All the other packages are optional. If you want to install the wxsmith and/or contrib packages, you must install the libwxsmithlib0 package first.

 



NOTE: Here is a complete command line for the above steps. Watch for word wrap. Replace wx2.6 with wx2.8 when needed.

 

(编者注:这里只是提供一个替换wx2.6到最新版(目前为止)2.8时的命令)

sudo apt-get install build-essential gdb libwxgtk2.6-0 libwxgtk2.6-dev wx2.6-headers wx2.6-doc wx-common


Without optional steps:

sudo apt-get install build-essential gdb libwxgtk2.6-0 libwxgtk2.6-dev wx2.6-headers wx-common

也许大家要问了,如果是想自己用源码从头到尾进行编译怎么办?我这里也有一个解决方案,
原理和步骤基本上和上文类似,大家可以参考一下:

1. Linux平台下编译安装wxGTK(以wxGTK-2.6.2 为例)
下载wxGTK-2.6.2.tar.gz(http://www.wxwidgets.org/)
tar zxvf wxGTK-2.6.2.tar.gz
cd wxGTK-2.6.2
./configure --enable-xrc --enable-monolithic --enable-unicode

make
make install

vi /etc/ld.so.conf
将/usr/local/lib加入后,运行ldconfig

可以通过以下操作的输出检查安装是否正确
wx-config --prefix
wx-config --libs
which wx-config

2.下载Code::Block
通过svn+http下载code::blocks
安装subversion,在 .subversion/servers 文件的global段设置代理服务器
svn checkout http://svn.berlios.de/svnroot/repos/codeblocks/trunk

如果不需要设置代理服务器,则可以用
svn checkout svn://svn.berlios.de/codeblocks/trunk
直接下载代码

3.编译安装Code::Block
直接运行bootsrtap可能会遇到宏AM_PATH_WXCONFIG 没定义等错误

1) cp /usr/local/share/aclocal/wxwin.m4 /usr/share/aclocal/wxwin.m4
2)./bootstrap
./configure
make
make install

至此全部ok了 经测验第一种方法完全可行,并且在我的Ubuntu8.04上顺利启动,哈哈,Ejoy it!