[转]Ubuntu(Linux)使用Eclipse搭建C/C++编译环境

首先是安装Eclipse,方法有两种:
       第一种是通过Ubuntu自带的程序安装功能安装Eclipse,应用程序->Ubtuntu软件中心,搜Eclipse安装即可。
       第二种方法是用命令:应用程序->附件->终端
                                       然后输入(中间可能需要你输入密码):
                                       sudo apt-get install eclipse
                                       sudo apt-get install eclipse-pde
                                       sudo apt-get install eclipse-jdt
       解释:
       这个命令是在解决安装CDT(也就是能编译C/C++代码的插件)问题时搜到的一个博文里面的,其原文地址为:ubuntu上使用eclipse进行C/C++代码编译
       对于第一次接触Linux的人说,也许不知道怎么使用命令,或者为什么使用命令。其实我也不是特别清楚,但我想跟系统有关吧,像Windows安装软件,都是exe格式的,然后双击,下一步下一步就可以,但是Linux应该是为了安全考虑或者什么的,需要使用命令来安装。 Ubuntu算是好的了,安装软件相对而言比较方便。像我刚开始耍的fedora,安装软件,简直让人崩溃,总是会少点依赖的库。使用命令安装软件,先要打开,终端(相当于DOS,或者说Windows附件里面的命令提示符),终端在应用程序->附件->终端。在终端里面输入密码,不像Windows那样,会有显示,比如像*那样的。如果在输入密码的时候,终端无任何符号显示,别担心,其实你刚才输入的都已经在终端上了,只是没有显示而已。继续输就是了,然后按下Enter键。
       注意:
       使用第一种方法安装时候,在安装CDT插件过程中,有可能会出现下面的错误
       An error occurred while installing the items
       session context was:(profile=PlatformProfile, phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Install, operand=null --> [R]org.eclipse.ant.ui 3.4.1.v20090901_r351, action=org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallBundleAction).
       The artifact file for osgi.bundle,org.eclipse.ant.ui,3.4.1.v20090901_r351 was not found.
       我搜了一下,说是eclipse-pde或是eclipse-jdt没安装上。其说明的网址如下:https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/477944。全英文的。所以,如果使用第一种方法的,最好,再在终端输入命令:
       sudo apt-get install eclipse-pde
       sudo apt-get install eclipse-jdt

       再安装CDT插件,方法如下:
       1、启动eclipse,
       2、选择Help->Install New Software...,在Work with的框框下复制下面的地址:  http://download.eclipse.org/releases/galileo
       3、选择Collaboration->Mylyn Bridge: C/C++ Development,安装,重启eclipse。
       4、同上述2、3,选择Programming Languages->Eclipse C/C++ Development,都选上吧,现在硬盘不贵的。重启eclipse,试试吧,有tutorial的。
       注意:
       在安装Mylyn Bridge: C/C++ Development,如果直接选择安装Eclipse C/C++ Development,会出现如下错误:
       Cannot complete the install because one or more required items could not be found.
       Software being installed: Mylyn Bridge: C/C++ Development 5.1.0.200909110608 (org.eclipse.cdt.mylyn.feature.group 5.1.0.200909110608)
       Missing requirement: Mylyn Bridge: C/C++ Development 5.1.0.200909110608   (org.eclipse.cdt.mylyn.feature.group 5.1.0.200909110608) requires 'org.eclipse.mylyn.context.core 3.0.0' but it could not be found

       注意:要记得安装C++必要工具,安装的是GCC工具链,Make等一系列开发工具,命令如下:
   sudo apt-get install build-essential

       要不然#include头文件的时候,会出现提示:Unresolved inclusion: <iostream>
posted @ 2012-08-19 01:11  Rabbit Nick  阅读(298)  评论(0编辑  收藏  举报