How to install plug-ins for C/C ++ development in eclipse

Source: Internet
Author: User

To use eclipse to develop C/C ++, follow these steps:

1. Install JRE

Go to Sun official website http://www.sun.com/download/ to download and install
Because eclipse is developed in Java, you need to use JRE. skip this step if you have installed jre before.
2. Install eclipse
This is a nonsense .. how to use it without installation!

Http://www.eclipse.org/
3. Install the eclipse Chinese plug-in
If you don't mind using the English interface, you can skip this step, the same as http://www.eclipse.org/
4. Install CDT
CDT is a plug-in that enables eclipse to develop C/C ++ programs. This is the main character of this article!

To enable eclipse to develop C/C Programs, you must install the CDT plug-in. You can find it at http://www.eclipse.org/cdt.

 

If your eclipse version is 3.0.x, you must install CDT 2.1.1.
If the installed eclipse version is 3.1, you must install CDT 3.0.

 

Install: copy the decompressed features and plugins to the directory where eclipse is installed, and then restart eclipse.

 

When you create a new project, you can see that the C and C ++ options are available, indicating that the installation is successful.

5. Install mingw
This is to make your computer have GCC, G ++ compiler, this is also necessary, otherwise it will not be able to compile.

CDT has been installed for your eclipse so far. You still need to install a compiler.

Therefore, you need to download the gnu c and C ++ compilers that can be used on Windows. Here, the download is: mingw.

Download URL: http://www.mingw.org/download.shtml
Find MinGW-3.1.0-1.exe on the download page

 

Choose to temporarily install C:/mingw

Add: Path: C:/mingw/bin to the environment variable;
For Windows users, right-click my computer and choose "properties"> "advanced"> "environment variables"> "system variables"> "path"
Add C:/mingw/bin; at the beginning.

Because the default file name for compilation in eclipse is make.exe, but the make file name after mingw installation is a mingw32-make.exe, so you can change the mingw32-make to make!

To enable CDT to use mingw for compilation, we need to go back to eclipse to set
Window-> C/C ++-> make-> New make project-> New Builder
Locate binary parser, cancel elf parser, and select PE windows parser.
6. Install C ++ formatter
CDT does not have the source code formatting tool, so it can be used to help. If you do not have this requirement, you can use it normally without installing it.

 

C ++ formatter is a tool used to typeset C/C ++ source code. It is really a life-saving thing for me to change the messy source code that has been changed, immediately let the source code back to the "elegant" state. Since the CDT compiler does not have an internal formatter, other tools are used. Here we want to use artistic style.
Astyle website in this http://sourceforge.net/projects/astyle under the latest version of unzip astyle, unzip and put it in the appropriate location

 

In eclipse, we must use an "external tool" to use it.

Run --> external tool-> external tool... and make the following settings:

 

Select "program" and click "new"
Name: formatter

Location:
Click "Browse File System..." and find the location of the extracted astyle.exe file.

Working directory:
$ {Workspace_loc:/$ {project_name }}

Independent variable:
-- Style = Kr $ {resource_name}

After filling in the information, click "close"

All installation has been completed.

 

--------------------------------------------

 

Next, try to write a small program.

Open eclipse> new project> C/C ++> managed make C ++ Project
On the navigator test, press right button-> Add-> source file
Get a source file name. Remember to add the suffix. cpp.
Type the source code

To typeset the source code of the program, click "execute"-> external tool-> select formatter

Sometimes the response is not sent immediately after clicking the button. In this case, you just need to switch the window and a dialog box will appear.

Click "run"-> run mode...-> Local C/C ++ Application
The execution result is displayed on the console !!

 

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.