linux 下怎样用 eclipse 编译 c++ linux 下怎样用 eclipse 编译 c++

linux \u4e0b\u600e\u6837\u7528 eclipse \u7f16\u8bd1 c++

\u4e00\u3001\u4e0b\u8f7d Eclipse IDE for c/c++ \u5b89\u88c5\u53051\u3001\u542f\u52a8 Linux \u7cfb\u7edf\uff0c\u4f7f\u7528\u6d4f\u89c8\u5668\u4ece eclipse \u5b98\u7f51\u4e0b\u8f7d Eclipse IDE for c/c++ \u5b89\u88c5\u5305\u3002
2\u3001\u4e0b\u8f7d\u65f6\uff0c\u8bf7\u6839\u636e\u4f60\u7684\u7cfb\u7edf\u7248\u672c\u4e0b\u8f7d\u76f8\u5e94\u7684\u5b89\u88c5\u5305\u3002 Linux \u670932 \u4f4d\uff0c64\u4f4d\u7684\u7248\u672c\u3002

\u4e8c\u3001\u5b89\u88c5 Eclipse IDE for c/c++1\u3001\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fdb\u5165 Eclipse \u5b89\u88c5\u5305\u6240\u5728\u76ee\u5f55\uff0c\u5728\u7a7a\u767d\u5904\u53f3\u51fb\u9f20\u6807\uff0c\u542f\u52a8\u7ec8\u7aef\u3002
2\u3001\u5b89\u88c5 Eclipse \u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5b89\u88c5\u4e86\u4ee5\u4e0b\u7ec4\u4ef6\u5e76\u66f4\u65b0\u5230\u6700\u65b0\u7248\uff1a
\uff081\uff09\u3001Java \u73af\u5883
\uff082\uff09\u3001gcc \u548c g++
\u68c0\u6d4b\u65b9\u6cd5\u6709\uff1a
\uff081\uff09\u3001\u67e5\u8be2 java \u7248\u672c\uff08\u901a\u7528\uff09\uff1ajava -version
\uff082\uff09\u3001\u67e5\u8be2 gcc \u7248\u672c\uff08\u7ea2\u5e3d\u7cfb\u5217\uff09\uff1arpm -qa gcc
3\u3001\u4e0b\u9762\u8fdb\u5165 eclipse \u7684\u5b89\u88c5\u73af\u8282
\u9996\u5148\uff0c\u767b\u9646 root \u5e10\u6237\uff0c\u952e\u5165\u547d\u4ee4 tar -zxvf \u5b89\u88c5\u5305\u540d\uff0c\u56de\u8f66\uff0c\u5c06\u538b\u7f29\u5305\u89e3\u538b\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u3002
4\u3001\u89e3\u538b\u5b8c\u6210\u540e\uff0c\u952e\u5165 ls \uff0c\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u76ee\u5f55\u591a\u4e86\u4e00\u4e2a\u76ee\u5f55 eclipse \u3002
\u952e\u5165 cp -r eclipse /opt/ \u5c31\u53ef\u4ee5\u4e86

\u65b9\u6cd5\u6b65\u9aa4\u5982\u4e0b\uff1a
1\u3001\u4e0b\u8f7djre\uff0ceclipse\uff0ccdt
\u5176\u4e2djre\u662fjava\u8fd0\u884c\u73af\u5883\uff0ceclipse\u9700\u8981\u5148\u88c5jre\uff0c\u624d\u53ef\u80fd\u8fd0\u884c\uff0ccdt\u662f\u5728 eclipse\u4e2d\u8fd0\u884cc\c++\u7a0b\u5e8f\u7684\u63d2\u4ef6\u3002
2\u3001\u5b89\u88c5
\uff081\uff09\u5148\u5b89\u88c5eclipse\uff0c\u6253\u5f00\u201c\u7ec8\u7aef\u201d\uff0c
\u8fdb\u5165\u8981\u201c\u5b89\u88c5\u8f6f\u4ef6\u201d\u7684\u76ee\u5f55\uff0c\u7136\u540e\uff0c\u89e3\u538beclipse-jee-galileo-SR1-linux-
gtk.tar.gz\u538b\u7f29\u5305\u547d\u4ee4\u662f\uff1a
sudo
tar \u2013zxvf
eclipse-jee-galileo-SR1-linux-gtk.tar.gz
\u5f97\u5230\uff1aeclipse\u6587\u4ef6\u5939
\uff082\uff09\u5b89\u88c5jre
\u5728\u7ec8\u7aef\uff0c\u8f93\u5165\uff1ash
jre-6u18-i586.bin\uff0c\u4e00\u76f4\u6309\u7a7a\u683c\uff0c\u7136\u540e\u8f93\u5165\u2018y\u2019\uff0c\u6309\u56de\u8f66\uff0c\u5219\u5f00\u59cb\u5b89\u88c5jre\u3002
\u5b89\u88c5\u597d\u4ee5\u540e\uff0c\u4f1a\u4ea7\u751f\u4e00\u4e2ajre1.6.0_18\u6587\u4ef6\u5939\uff0c\u7136\u540e\u5c06\u8be5\u6587\u4ef6\u5939\u62f7\u8d1d\u5230eclipse
\u6587\u4ef6\u5939\u4e0b\u3002\u901a\u8fc7\u5728\u7ec8\u7aef\u8f93\u5165\uff1asudo
cp \u2013r
jre1.6.0_18 eclipse/jre
\u5230\u73b0\u5728\u4e3a\u6b62\uff0c\u53ef\u4ee5\u8fd0\u884ceclipse\u8f6f\u4ef6\uff0c\u65b9\u6cd5\u662f\u6253\u5f00eclipse\u6587\u4ef6\u5939\uff0c\u76f4\u63a5\u53cc\u51fb eclipse\u56fe\u6807\u5373\u53ef\u3002
\uff083\uff09\u5b89\u88c5cdt
\u5728\u7ec8\u7aef\u8f93\u5165\uff1aunzip
cdt-master-6.0.1.zip \u2013d
cdt\uff0c\u53ef\u4ee5\u628acdt-master-6.0.1.zip\u89e3\u538b\u5e76\u4e14\u5b83\u7684\u5185\u5bb9\u5b58\u653e\u5728cdt\u6587\u4ef6\u5939\u4e0b\u3002
\u518d\u8f93\u5165\uff1asudo cp \u2013r cdt/plugins/eclipse/\uff0c\u5219\u5c06cdt\u4e0bplugins\u7684\u5185\u5bb9\u62f7\u8d1d\u5230eclipse\u4e0bplugins\u6587\u4ef6\u5939\u3002
\u6700\u540e\uff0c\u8f93\u5165sudo cp \u2013r cdt/features/eclipse/\uff0c\u5219\u5c06cdt\u4e0bfeatures\u7684\u5185\u5bb9\u62f7\u8d1d\u5230eclipse\u4e0bfeatures\u6587\u4ef6\u5939\u3002
\u5230\u73b0\u5728\uff0c\u5b89\u88c5\u5df2\u7ecf\u5b8c\u6210\u3002

 安装

(1)先安装eclipse,打开“终端”


进入要“安装软件”的目录


然后,解压eclipse-jee-kepler-RC3-linux-gtk.tar.gz压缩包

命令是 tar –zxvf  eclipse-jee-kepler-RC3-linux-gtk.tar.gz

得到:eclipse文件夹

(2)安装jre

在终端,输入:rpm -ivh jre-7u21-i586.rpm,开始安装jre。

安装好以后,会在/usr/java/产生一个jre1.7.0_21文件夹,然后将该文件夹拷贝到eclipse文件夹下。通过在终端输入:cp –rjre1.6.0_18 eclipse/jre

到现在为止,可以运行eclipse软件,方法是打开eclipse文件夹,直接双击eclipse图标即可。

(3)安装cdt

在终端输入:unzip cdt-master-8.1.2.zip –d cdt,可以把cdt-master-8.1.2.zip解压并且它的内容存放在cdt文件夹下。

再输入:cp –r   cdt/plugins/ eclipse/,则将cdt下plugins的内容拷贝到eclipse下plugins文件夹。

最后,输入cp –r   cdt/features/ eclipse/,则将cdt下features的内容拷贝到eclipse下features文件夹。

到现在,安装已经完成。

3.       运行c++程序


在运行c++程序之前,需要在终端输入:sudo apt-getinstall build-essential,这条命令的含义是安装c++编译器,调试软件等。

打开eclipse,建立工程,如下图所示:

选择“c++ project”,点击“next”,新建一个hello world工程:



扩展阅读:linux cal ... linux 教程 ... linux curl ... linux awk命令 ... Linux 简介 ... Linux 内核 ... linux kill命令详解 ... line in插口怎么使用 ... linux expect 详解 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网