在Windows中,搭建一个C/C++的开发环境比较麻烦。
常见二种选择:
①简单小巧,Eclipse Neon2 [Eclipse IDE for C/C++ Developer] & MinGW或Cross GCC
②庞大臃肿,Visual Studio 2012 -> C/C++部分
最终我选择:
Ubuntu 16.04LTS中搭建Eclipse Neon2 [Eclipse IDE for C/C++ Developer]
Linux中自带GCC,这是最套的好。
安装方法:
①首先->安装Java的JDK,②再安装 ->Eclipse IDE for C/C++ Developer。③其次是使用。
具体参考命令:
①JDK
//登陆root
glp@ubuntu:/$ su
Password:
//切换目录
root@ubuntu:/# cd /opt/
//下载JDK
root@ubuntu:/opt# wget http://mirrors.linuxeye.com/jdk/jdk-8u112-linux-x64.tar.gz
//解压JDK
root@ubuntu:/opt# tar -zxvf jdk-8u112-linux-x64.tar.gz
//编辑JDK环境①
root@ubuntu:/opt# vim /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
source /etc/profile.d/java.sh
exit 0
//编辑JDK环境②
root@ubuntu:/opt# vim /etc/profile.d/java.sh
export JAVA_HOME=/opt/jdk1.8.0_112
export CLASSPATH=$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
:wq
②Eclipse
//下载
root@ubuntu:/opt#wget http://ftp.yz.yamagata-u.ac.jp/pub/eclipse/technology/epp/downloads/release/neon/2/eclipse-cpp-neon-2-linux-gtk-x86_64.tar.gz
//解压
root@ubuntu:/opt#tar -zxvf eclipse-cpp-neon-2-linux-gtk-x86_64.tar.gz
③使用
//制作快捷启动图标
root@ubuntu:/opt#vim /eclipse.desktop
[Desktop Entry]
Name=Eclipse C
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse
//移动图标到桌面
root@ubuntu:/opt#cp eclipse.desktop /home/glp/Desktop
Workspace使用默认。
新建示例程序,运行。
运行报错:
这是每一使用者犯错的地方。要先 Build Project 项目,再 Run As。从Console窗口看结果。
至此结束。