ubuntu安装blocklocks与简单的设置方法

来源:互联网 发布:拳皇13优化补丁 编辑:程序博客网 时间:2024/04/28 19:11

ubuntu 下code blocks 安装全过程

(一)安装步骤:


1.先把编译环境,C库、C++库和Boost库装好,如下:

sudo apt-get install build-essential
* 有可能安装 build-essential 后gdb就已经安装过了
   sudo apt-get install gdb

2. 在 Ubuntu 软件中心 中安装 Code::Blocks IDE

3. 安装 Code::Blocks 的调试组件 Valgrind 用来探测内存泄露的:

sudo apt-get install valgrind

4. 安装外围爱好者根据需要自行编译并贡献的软件
sudo apt-get install codeblocks-contrib

5. 安装 wxWidgets 开发相关项:(注:安装前到 www.wxWidgets.org上看一下最新版本 )

 sudo apt-get install libwx*.deb

sudo apt-get install libwxbase2.8-dbg
sudo apt-get install libwxbase2.8-dev

sudo apt-get install libwxgtk2.8-dbg
sudo apt-get install libwxgtk2.8-dev 

sudo apt-get install wx2.8-i18n

sudo apt-get install wx2.8-doc
sudo apt-get install wx2.8-examples

sudo apt-get install wx-common

开始使用Code::Blocks了,应用程序->编程->Code::Blocks IDE。

Code::Blocks和wxWidgets整合非常好,几乎不用做任何额外的配置。

(三)更新codeblocks 10.05




大概步骤:
1.先进入“系统”--》“系统管理”--》“新立德软件包管理器“,搜索curl,双击选中,之后点“应用” 如下图:
图片
2.关闭“新立德软件包管理器“,打开:应用程序”--》“附件”--》“终端”
输入 :
curl http://apt.wxwidgets.org/key.asc | sudo apt-key add -

回车。
3.进入“系统”--》“系统管理”--》“软件源”
切到“其他软件”标签,点添加 ,分别添加下面2个链接:
deb http://apt.wxwidgets.org/ lucid-wx main

deb-src http://apt.wxwidgets.org/ lucid-wx main


关闭
4. 打开”应用程序“--》”附件“--》”终端“ ,执行以下命令:
sudo apt-get update
sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n
5. 现在开始安装codeblocks10 ,从 http://www.codeblocks.org/downloads/26 下载codeblocks


这里选择linux版本 :codeblocks-10.05-1-debian-i386.tar.bz2
图片
(至于下面的codeblocks-10.05-1-debian-dbg-i386.tar.bz2,我没有试过,应该也可以)
6. 解压下载的文件,得到很多.deb文件
7.进入i386文件目录,打开”终端“,执行sudo dpkg -i *.deb
完成后,可在”应用程序“--》”编程“中找到




安装后如果会出现依赖错误,codeblocks: relocation error: /usr/lib/libcodeblocks.so.0: symbol _Z18wxSafeConvertWX2MBPKw, version WXU_2.8.2 not defined in file libwx_baseu-2.8.so.0 with link time reference
重做2 3 4步。

使用说明:

Ubuntu下CodeBlocks更改调试终端 
  在环境设置里进行如下设置:

把Terminal to launch console programs那个选项改成gnome-terminal -t $TITLE -x 

原来是xterm -T $TITLE -e 

gnome-terminal和xterm的参数表示方法不一样。


汉化方法:

/usr/share/codeblocks/新建locale文件夹然后把 codeblocks.mo 拷贝到locale文件夹内。重现启动codeblocks 自动转换为中文界面。
下载地址:
http://forum.ubuntu.org.cn/download/file.php?id=56568

1.可以自己写Makefile:

 在Project的属性中指定使用custom makefile即可。和visual studio一样,可以定义很多编译和link过程中的参数,包括定义编译参数等,这些都可以在Project的build option或compiler/debugger settings中找到。
 对于一些使用autoconf/automake的项目来说,我想只有新建一个project,然后将源码导入才行。不过,现在已经有人开始做autoconf/automake的code blocks的plugin了。

2.可以定义快捷键:

 遗憾的是,只能给菜单中出现的项目定义快捷键,对于比如editor中右键弹出的context menu中的项目无法定义快捷键。
 Settings -> Editor -> Keybord shortcut里面可以定义快捷键。
 注:[Edit]->[Complete code]的快捷键Ctrl - Space(与输入法冲突)要改成Ctrl - k
   (不限为Ctrl -k,只要不冲突,任用你喜欢的键)。

 management, log, message panel等都不能autoshow/autohide。要么关闭,要么显式。也不能dock成一条,吸附在屏幕两边。对于这个问题,我使用的办法是:给display/hide这些pane定义快捷键,使用这些快捷键来显式或隐藏这些pane,效果也不错。

3.定制F1帮助系统
 在Settings -> Environment -> Help files中新建一个entry,名为man,接着的对话框选no,然后手动在下面的path中填写: man:/usr/share/man 
 将default (使用F1快捷键)勾上。这样就可以使用manpage了。在editor中,将光标停在想要查询的内容上面,按F1,就会弹出一个panel,里面就有查询内容的man手册,非常的方便。比如printf,按F1,弹出的panel中就显示printf的man手册。
在 [终端] 下执行下行语句,安装GNU C标准
sudo apt-get install manpages-dev          // C API 
sudo apt-get install manpages-posix        // posix function
sudo apt-get install manpages-posix-dev // posix develop documents
sudo apt-get install glibc-doc                   // C API
sudo apt-get install stl-manual                 // STL
sudo apt-get install libstdc++6-4.1-doc    // 注:我写这篇文章时,安4.1这个man std::string可以
sudo apt-get install libstdc++6-4.3-doc    // C++ API,建议先安这个试,再试4.1
sudo apt-get install manpages-zh            // 中文文档
修改man默认的语言
sudo gedit /etc/manpath.config
把里面所有含 /usr/share/man 的行拷贝添加到其下一行并改成 /usr/share/man/zh_CN
中文在上,英文在下,如下所示:
(注:以MANDB_MAP开头的就不要改了不然会有如下错误提示的
           man: 无法解析 /usr/share/man/zh_CN/man3/std::vector.3.gz: 没有该文件或目录)
MANDATORY_MANPATH /usr/share/man/zh_CN

MANPATH_MAP /bin /usr/share/man/zh_CN
MANPATH_MAP /bin /usr/share/man
MANPATH_MAP /usr/bin /usr/share/man/zh_CN
MANPATH_MAP /usr/bin /usr/share/man
MANPATH_MAP /sbin /usr/share/man/zh_CN
MANPATH_MAP /sbin /usr/share/man
MANPATH_MAP /usr/sbin /usr/share/man/zh_CN
MANPATH_MAP /usr/sbin /usr/share/man
MANPATH_MAP /usr/games /usr/share/man/zh_CN
MANPATH_MAP /usr/games /usr/share/man
保存后退出

4.自动补全功能设置
  每个新建工程都要在菜单[Project] -> [Properties...] -> [C/C++ parser options]中添入头文件所在目录,这样自动补全与信息提示功能才可正常工作,如下是标准库头文件的目录:
/usr/include
/usr/include/bits
/usr/include/c++/4.3/tr1
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.3/include
/usr/lib/gcc/i486-linux-gnu/4.3.3/include
下面这个是socket的文件路径
/usr/include/sys
/usr/include/netinet
/usr/include/arpa
添上后不是立即起效,过一段时间后你就发现功能突然出现!

5. 修改 GNU ARM GCC Compiler
1. [Settings] -> [Compiler and debugger settings]
    将Setected compiler 修改为GNU ARM GCC 编译器。


2. 在同页面选择 [Toolchain executables]选项卡中的[program files]选项页,
    1) 先修改 Compiler's installation directory 为你的ARM GCC Compiler安装所在地址;
    2) 再选择替换C编译器(arrm-linux-gcc)、C++编译器(arm-linux-g++)、
        动态库链接器(arm-linux-g++)、静态库链接器(arm-linux-ar)、
        调试器(arm-linux-gdb);

    注:make程序还用/usr/bin/make,即GNU GCC 自带的即可!

6. 智能化配置:
一、[Settings] -> [Editor...] -> "Code-completion and symbols browser"中
1. 将 Keyword sets to additionally include 中1到9都勾上,
    1 ~ 9 对应的关键字可在 "Syntax highlighting" 的 [keywords...]按钮 中设置,
    默认其中 1 是 C++ 关键字,3 是 Doxygen 关键字;
2. 将 Delay for auto-kick-in when typing [.::->] 拉到 200ms,这样快点出来提示
3. 将 Automatically launch when typed # letters 中的4改成2,这样打两个字母就会有提示了
4. 将 Case-sensitive match 的勾去掉,它会帮你纠正大小写

二、[Settings] -> [Editor...] -> “Abbreviation” 中
定义了许多缩写(还可以自定义),只要输入这些缩写,并按Ctrl+J,就可以自动完成常用的代码框架,并可将光标放在恰当的地方(自定义时用|表达),常用的有:guard、class、switch等。

7. 快捷键:
Ctrl + 滚轮          代码的字体会随你心意变大变小

右键 + 拖动鼠标    省得去拉(尤其是横向)滚动条,相关设置:Mouse Drag Scrolling

Atl + 拖动鼠标      实现部分选择(只选中区域内的字符,而不会包含它们所在行的其他字符)。
Ctrl+D                可复制当前行或选中块
Ctrl + 拖动鼠标    复制到新位置

Ctrl+Shift+C       注释掉当前行或选中块
Ctrl+Shift+X       解除注释

Tab                      缩进当前行或选中块
Shift + Tab          减少缩进

F2                        显隐下方Logs & others栏
Shift+F2              显隐左方的Management栏

Ctrl+G                   到达指定行
ALT+G                  到达指定文件
Ctrl+Alt+G            到达指定函数(支持头文件中的函数定义)
F11                       切换源文件与头文件

Ctrl + PageUp        到达上一个函数
Ctrl + PageDown   到达下一个函数。

Ctrl + B                  添加书签
Alt + PageUp 和
Alt + PageDown    可以切换书签

Ctrl + Shift + B      可找到匹配的括号。

8. 备份~/codeblocks/Default.conf,就不会丢失你的配置:
在终端里执行 cb_share_config 这个命令,会打开如下窗口:


0 0
原创粉丝点击