Linux C/C ++ programs have been widely used but are constantly updated. Here we will introduce how to install and use Linux C/C ++ programs, help you install and update the Linux C/C ++ Program System. Why use Eclipse in Linux to develop Linux C/C ++ programs?
Linux C/C ++ is mainly used for development of Linux C/C ++ programs, whether it is Kernel or Application. Traditionally, programs are developed in Linux. In the text mode, you can use a vi or other text editor to write Linux C/C ++ programs and then use gcc for compiling in Command line, to debug, 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 Linux 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 Linux 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, Linux C/C ++ programs, 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.
In Linux, how does one install Eclipse and CDT?
Eclipse is installed by Linux Distribution, and Fedora 5 contains Eclipse and CDT.
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)
Install JRE in Linux C/C ++
[Root @ localhost ~] # Mkdir/usr/local/java
(Download the archive jre-1_5_0_09-linux-i586-rpm.bin to the/usr/local/java directory)
(Super User Mode)
[Root @ localhost ~] # Su
[Root @ localhost ~] # Cd/usr/java
(Change the permission of the downloaded file to executable)
[Root @ localhost java] # chmod a + x jre-1_5_0_09-linux-i586-rpm.bin
(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)
(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)
(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)
(Test whether Java is successfully installed)
[Root @ localhost ~] # Java-version
Install the Eclipse SDK in Linux C/C ++
(Download eclipse-sdk-3.2.1-linux-gtk.tar.gz to the desktop)
[Root @ localhost ~] # Cd/usr/local
[Root @ localhost local] # cp ~ Desktop/eclipse-SDK-3.2.1-linux-gtk.tar.gz.
(Decompress eclipse-sdk-3.2.1-linux-gtk.tar.gz)
[Root @ localhost local] # tar-zxvf eclipse-SDK-3.2.1-linux-gtk.tar.gz
[Root @ localhost local] # cd eclipse
(Execute Eclipse)
[Root @ localhost eclipse] #./eclipse
(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)
Install CDT in Linux C/C ++ Program
(Download the file org.eclipse.cdt-3.1.1-linux.x86.tar.gz to the desktop)
[Root @ localhost ~] # Cp ~ // Desktop/org.eclipse.cdt-3.1.1-linux.x86.tar.gz.
(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)
(Install CDT plugin)
[Root @ localhost ~] Cp-r eclipse/plugins/./usr/local/eclipse/plugins/
(Start Eclipse with support for C and C ++ Projects)
C. How to develop Linux C/C ++ programs on Eclipse?
Create a Hello Word project
Create a C/C ++ project
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 .)
Enter Project name
Select the Project type (such as the Execution file or Library). Select the execution file here)
Additional settings
Open Associated Perspective? (Select Yes to continue)
Create a C ++ Source File
Enter the C ++ Source File alias name.
Enter the C ++ program code
Execute the program (displayed in the Console area below)
In Eclipse CDT, how does one Debug C/C ++ programs?
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.
Start Debug
Debug settings. Press Debug to start debugging.
One step to show variable changes
Conclusion
Eclipse provides a complete IDE environment for Linux C/C ++ program development. In fact, with my many IDE experiences, apart from 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.
See Also Eclipse + CDT + MinGW Installation Method
Reference
1. Instructions on manually downloading and installing Java Runtime Enrironment (JRE) for Linux
Http://www.java.com/zh_CN/download/help/5000010500.xml)
2. Eclipse 3.0 CDT on Linux
Http://www.autexier.de/jmau/dev/CDT/cdt.html)
The above is the installation of Linux C/C ++ program.
- Command Daquan: Linux crond Parsing
- Easy understanding of Linux chgrp and chown commands
- The Suse Linux crontab tool runs normally.
- How to switch IP addresses in Suse Linux
- Linux Chrome has better performance than Windows and Mac