您的位置:首页 > 其它

ubuntu 12.04 下 CodeBlock的安装

2013-06-20 15:23 253 查看
今天自己把CODEBLOCK安装了一下,给大家参考

关于安装过程总结起来可以分为以下几个步骤:

1. 首先要安装 wxGTK ,这个是必须的,否则 Code::Blocks 将无法成功安装。因为 Code::Blocks 是基于 wxWidgets (wxGTK )开发出来的。

wxGTK 最新版本下载地址: http://www.wxwidgets.org/downloads/

我所使用的版本下载地址为:

http://nchc.dl.sourceforge.net/sourceforge/wxwindows/wxGTK-2.8.10.tar.gz

2. 编译安装 wxGTK (以 wxGTK-2.8.10 为例)

依次输入如下命令进行安装:

tar zxvf wxGTK-2.8.10.tar.gz

cd wxGTK-2.8.10

./configure --enable-xrc--enable-monolithic --enable-unicode

make

make install

其中的 make 过程时间会相当的长,请耐心等待,如果没有错误提示,说明安装比较顺利!

这里可能会碰到一定的错误:

1. checking for GTK+ - version >= 2.0.0... no

2. *** Could not run GTK+ test program, checking why...

3. *** The test program failed to compile or link. See the file config.log for the

4. *** exact error that occured. This usually means GTK+ is incorrectly installed.

5. configure: error:

6. The development files for GTK+ were not found. For GTK+ 2, please

7. ensure that pkg-config is in the path and that gtk+-2.0.pc is

8. installed. For GTK+ 1.2 please check that gtk-config is in the path,

9. and that the version is 1.2.3 or above. Also check that the

10. libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config

11. --libs' are in the LD_LIBRARY_PATH or equivalent.

解决的办法是:sudo apt-get install libgtk2.0-dev 因为有一写库没安装。

3. 下载 Code::Block

Code::Block 最新版本的下载地址: http://www.codeblocks.org/downloads/

我所使用的版本下载地址为:

http://ncu.dl.sourceforge.net/sourceforge/codeblocks/codeblocks-8.02-src.tar.bz2

4. 编译安装 Code::Block (以 codeblocks-8.02 为例)

依次输入如下命令进行安装:

tar jxfcodeblocks-8.02-src.tar.bz2

cd codeblocks-8.02

./configure –prefix=/usr

make

make install

这里面将其安装于 /usr 下,如果在 /usr/local 下会提示有些 so 文件找不到,按照 Linux 的习惯而言,系统包都是安装在 /usr 下,而用户使用的应用软件默认安装于 /usr/local 下,如果不指定话会因为 PATH 不够,无法包含 Lib 库的情况,当然可以自己添加。

这里make 可能会出问题 :

prefix.cpp: 在函数‘char* br_extract_dir(const char*)’中: prefix.cpp:396:26。。。。。。。。。。。。。。。。

不要担心: vi 进入那个文件把文件修改一下 把396行改为: end =(char *) strrchr (path, '/');

还有一行也这样该,就所在前面加一个(char *)这是因为新版本的G++不支持报错功能了。

5. 修改库文件路径指向

因为在安装 wxGTK 时没有指定路径,因此, wxGTK 被装到了 /usr/local/lib 下,当然,如果安装 wxGTK 时已经指定了路径,即加入 “-prefix=/usr” 这个参数后,则可以省略这一步。

库文件路径指向方法:

vi/etc/ld.so.conf

在文件最后输入: /usr/local/lib

保存后,运行 /sbin/ldconfig

按照上述配置路径就应该没有什么问题,否则就会出现运行 Code::Blocks 之后,一闪就自动关闭了,本人就是这种情况,通过修改就解决了。

6. 验证安装是否正确

可以通过以下操作的输出检索安装是否正确

wx-config--prefix

wx-config --libs

which wx-config

7. 创建快捷方式
单击DASH 主页 在里面输入CODEBLOCK 按住ALT键,把图标拖到桌面就可以了。

9. 中文语言包

需要下载一个中文语言包: d2school_codeblocks_chinese_locale.7z

下载地址:

http://www.d2school.com/codeblocks/download/d2school_codeblocks_chinese_locale.7z

在 Linux 下解压后,创建一个目录 mkdir -p/usr/share/codeblocks/locale 将解压出来的 mo 文件复制到下面,再打开就是中文的了,

有人说还需要下面的操作,其实是不需要的,打开之后就是中文了:

启动 Code::Blocks ,选择 Settings à Enviornment à View à Internationalization à

Chinese(Simplified) 即可。

10. 更改编译器的默认路径

费了老半天的劲把 code::blocks 装上去了,兴奋地赶快想敲个 HELLOWORLD 程序,结果呢,又折腾了半天点了构建、运行 … 等等按钮都是一点反应都没有。

原因很简单 Fedora 上编译器默认的安装路径是 /usr/lib ,但实际上,我们把 code::blocks 安装到了 /usr 下面,所以需要把默认的路径改为 /usr : setting à compiler
andddebuger à Toolchainexecutables 中将 compiler’s
installtiondirectory 改为 /usr 就行了, code::blocks 自动检测结果是 /usr/lib 。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: