Ubuntu 编程环境搭建

One,

apt-get install build-essential

 

http://hi.baidu.com/mrprogrammer/blog/item/294b512b17efb993023bf62f.html


Two,

1.
in synaptic install the cscope
2.
the dirctory of the project
# cscope -Rbkq
# vim file.c
then:
cs add cscope.out
...


http://dslab.lzu.edu.cn:8080/members/zhangwei/doc/cscope-HOWTO.txt
3.2 Build the database for cscope

3.2.1 the simpest method

>> cscope -Rbkq

[ -R makes Cscope parse all subdirectories, not just the current directory
  -b which tells Cscope to just build the database, then exit, otherwise,
     it will enter into the cscope comand line.
  -q causes an additional, 'inverted index' file to be created,
     which makes searches run much faster for large databases.
  -k sets Cscope's 'kernel' mode--it will not look in /usr/include for any
     header files that are #included in your source files]

3.2.2 the complex method

we can select what we want to add to the database for cscope, it is supported
with the option -i or the default file cscope.files.
in this method, we can exclude the files not useful, or include the files we
have interst on.
so we can use the command "find" to list the files you have interest on of
your
 project with the absolute path, just like this:


>> cd /
>> find /my/project/dir -name '*.java' >/my/cscope/dir/cscope.files

[by default Cscope only parses files with the .c, .h, .y, or .l extensions, so
we need to add these files have .java extensions to the cscope.files or other
files u want if u use the -i option instead]

After create a file including the "interest" files list with their absolute
paths, we can use the following command to generate the database cscope.out.

>> cscope -bkq // R?

3.2.3 Update the cscope database

if u have change some files in your project, u can use the "-U" option with
the
first method, and with the second method, u can update the file list in the
file
cscope.files or the filename u defined yourself with the "find" command. and

then
execute "cscope -bkq" command.






### 配置 Ubuntu 上的 C++ 开发环境Ubuntu 系统上配置 C++ 开发环境需要安装必要的编译器、工具链以及开发工具。以下是详细的配置说明: #### 1. 安装基础编译工具 为了支持 C++ 编译,需要安装 `build-essential` 包,它包含了 GCC、G++ 和其他必要的工具。 ```bash sudo apt-get update sudo apt-get install build-essential ``` 上述命令会安装 GCC 和 G++ 编译器[^1]。 #### 2. 验证编译器是否正确安装 通过以下命令检查 GCC 和 G++ 的版本号,确认它们已经正确安装: ```bash gcc --version g++ --version ``` 如果输出了版本信息,则表示安装成功[^4]。 #### 3. 安装文本编辑器或集成开发环境 (IDE) 可以安装 Vim 或其他编辑器作为代码编辑工具: ```bash sudo apt-get install vim ``` 此外,还可以选择安装更高级的 IDE,例如 Code::Blocks 或 CLion。对于轻量级开发,Vim 是一个不错的选择[^1]。 #### 4. 测试 C++ 编译环境 创建一个测试文件并验证环境是否正常工作: ```bash mkdir ~/cpp_test cd ~/cpp_test vim main.cpp ``` 在 `main.cpp` 中输入以下内容: ```cpp #include <iostream> using namespace std; int main() { cout << "Hello, World!" << endl; return 0; } ``` 保存并退出后,使用以下命令编译和运行程序: ```bash g++ -o hello main.cpp ./hello ``` 如果输出 `Hello, World!`,则表示环境配置成功[^1]。 #### 5. 可选:安装 CMake 工具 CMake 是一个跨平台的构建工具,适合用于管理复杂的 C++ 项目。可以通过以下命令安装: ```bash sudo apt-get install cmake ``` 验证安装是否成功: ```bash cmake --version ``` 如果需要更高版本的 CMake,可以从官网下载 tar.gz 压缩包并解压到指定目录,然后将解压后的二进制路径添加到系统环境变量中[^5]。 #### 6. 可选:安装 GTK 开发环境 如果需要开发图形界面应用程序,可以安装 GTK 相关库: ```bash sudo apt-get install gnome-core-devel sudo apt-get install libglib2.0-doc libgtk2.0-doc sudo apt-get install devhelp glade-gnome glade-common glade-doc ``` 这些工具可以帮助开发者设计和调试 GTK 应用程序[^3]。 ### 注意事项 - 如果系统中未启用 root 用户,可以通过以下命令启用: ```bash sudo passwd root ``` - 确保系统已更新 (`sudo apt-get update`),以避免因软件包过时导致的问题。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值