Install linux eclipse C ++

Source: Internet
Author: User
Tags gtk


Linux is a platform based on C/C ++ development. It mainly uses C/C ++ development for both kernel and application. Traditionally, programs are developed in Linux. In the text mode, after the C/C ++ program is written in the VI and other text editors, the C/C ++ program is saved and compiled using GCC in command line. To debug the program, use GDB.

This development method is not highly productive. If it is just a small program for development and learning, it will not affect much. However, if you want to develop large projects, there will be a large number of program archives, project or solution management is required. In debug, breakpoint addition, single-step execution, and variable change observation all require a more visual approach to increase productivity, because the current programming languages are very huge and there are complex libraries, it is very difficult for programmers to memorize all the program syntax and function names, so the syntax prompt (intelliisense) is very important, and these must be achieved by IDE.


On the Windows platform, to develop C/C ++ programs, we have Microsoft Visual Studio and Borland C ++ builder available. These are all very useful ides, but unfortunately it can only be used in windows, but on the Linux platform? For the following reasons, I recommend using eclipse to develop C/C ++ programs:

1. Eclipse is an IDE written in Java. Therefore, it can be used across platforms. Therefore, eclipse can be used on both Linux and Windows platforms to reduce developers' familiarity with IDE learning curves.

2. although eclipse is mainly used to develop Java programs, eclipse is actually a "universal language" Ide. After plug-in is mounted, you can develop various language programs in eclipse, therefore, after we have mounted the CDT (C/C ++ Development Toolkit), we can develop C/C ++ programs in eclipse. In addition, the current mainstream programming languages, for example, C/C ++, C #, Java, PHP, Perl, Python, Ruby, REBOL, JavaScript, SQL, XML, and UML can all be written on Eclipse, therefore, you only need to familiarize yourself with the Eclipse IDE environment. If you develop other language programs in the future, you do not have to re-learn the IDE environment.

3. most importantly, eclipse and CDT are open source and completely free, which is quite easy to obtain. In fact, fedora 5 already contains eclipse and CDT, although the default fedara 5 installation does not contain eclipse, you only need to manually add and select.


B. How to install eclipse and CDT in Linux?
I. Eclipse is installed by Linux distribution, and Fedora 5 contains eclipse and CDT.

Ii. Manual Installation
1. download files
A. Download JRE (Java Runtime Environment ). Http://java.sun.com/javase/downloads/index.jsp)

B. Download the eclipse SDK. Http://www.eclipse.org/downloads)

C. Download CDT. Http://www.eclipse.org/cdt/downloads.php)

2. Installation
A. Install JRE
I. [root @ localhost ~] # Mkdir/usr/local/Java

II. (download the archive jre-1_5_0_09-linux-i586-rpm.bin to the/usr/local/Java directory)

III. (Super User Mode)
[Root @ localhost ~] # Su

Iv. [root @ localhost ~] # Cd/usr/Java

V. (change the permission of the file you downloaded to executable)
[Root @ localhost Java] # chmod A + x jre-1_5_0_09-linux-i586-rpm.bin

Vi. (start the installation process)
[Root @ localhost Java] #./jre-1_5_0_09-linux-i586-rpm.bin
(The binary license agreement is displayed, and the next page is displayed by control. After reading the license agreement, enter "yes" to continue the installation. At this point, decompress to generate a jre-1_5_0_9-linux-i586.rpm)

VII. (install jre-1_5_0_9-linux-i586.rpm)
[Root @ localhost Java] # rpm-IVH jre-1_5_0_9-linux-i586.rpm

(JRE will be installed in the/usr/Java/jre1.5.0 _ 09 directory)

VIII. (set environment variables so that Linux can find JRE)
[Root @ localhost Java] # vi/etc/profile
(Add the following content to the end of the file)

1 Path = $ path:/usr/Java/jre1.5.0 _ 09/bin
2 Export java_home =/usr/Java/jre1.5.0 _ 09
3 Export classpath = $ java_home/lib :.

(Restart Linux after saving the disk)

IX. (test whether Java is successfully installed)
[Root @ localhost ~] # Java-version

B. Install the eclipse SDK
I. (download the file eclipse-sdk-3.2.1-linux-gtk.tar.gz to the desktop)

Ii. [root @ localhost ~] # Cd/usr/local

Iii. [root @ localhost local] # CP ~ Desktop/eclipse-SDK-3.2.1-linux-gtk.tar.gz.

Iv. (decompress eclipse-sdk-3.2.1-linux-gtk.tar.gz)
[Root @ localhost local] # tar-zxvf eclipse-SDK-3.2.1-linux-gtk.tar.gz

V. [root @ localhost local] # cd eclipse

Vi. (execute eclipse)
[Root @ localhost eclipse] #./eclipse

VII. (select a workspace)
(Check use this as the default and do not ask again. This window will not appear in the future)

(This error occurs when eclipse is executed for the first time. Because there is no eclipse configuration file, it cannot be read. If eclipse is executed for the second time, this error message is not displayed. Press OK to continue .)

(Eclipse main screen)

C. Install CDT 
I. (download the file org.eclipse.cdt-3.1.1-linux.x86.tar.gz to the desktop)

Ii. [root @ localhost ~] # CP ~ // Desktop/org.eclipse.cdt-3.1.1-linux.x86.tar.gz.

Iii. (decompress org.eclipse.cdt-3.1.1-linux.x86.tar.gz)
[Root @ localhost ~] # Tar-zxvf org.eclipse.cdt-3.1.1-linux.x86.tar.gz
(The file will be resolved ~ /Eclipse directory)

IV. (install CDT plugin)
[Root @ localhost ~] CP-r Eclipse/plugins/./usr/local/Eclipse/plugins/

V. (start eclipse with support for C and C ++ projects)

C.How to Develop C/C ++ programs in eclipse?
I. Create a hello word project

1. Create a C/C ++ Project

2. select managed make C ++ Project (if you select managed make C ++ project, eclipse will automatically create make file for us; if you select standard make C ++ project, you must write make file by yourself .)

3. Enter the project name

4. Select the project type (such as the Execution file or library). Select the execution file here)

5. Additional settings

6. Open associated perspective? (Select YES to continue)

7. Create a C ++ source file

8. Enter the C ++ source file alias name.

9. Enter the C ++ program code

10. Execute the program (displayed in the console area below)

Ii. How to debug C/C ++ programs in eclipse CDT?
1. In eclipse, debug is like debugging in general ide. You only need to press twice on the left side of the program code to add breakpoint.

2. Start debug

3. Set debug and press debug to start debug.

4. One-step execution to show variable changes

E. Conclusion
Eclipse provides a complete IDE environment for Linux development in C/C ++. In fact, with my many ide experiences, besides Visual Studio, eclipse is also easy to use and directly pursued Visual Studio, and beyond Borland C ++ builder and Dev C ++, although installation is troublesome, as long as you follow the step-by-step settings described in this article, you can complete eclipse settings. If you want to use GCC compiler on Windows, you are advised to use a combination of eclipse + CDT + mingw.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.