Methods for using Cygwin under Eclipse (play gcc/g++ and gdb with Eclipse under Windows)

Source: Internet
Author: User

Http://www.cnblogs.com/skyofbitbit/p/3708216.html

Online configuration ECLIPSE+CDT articles are not many, come and go also on so several, I tried, or outdated, or not very comprehensive, in short, I have not been able to solve the problems encountered by the perfect solution, even to the StackOverflow site did not solve the problems I encountered, It seems that the use of people really very little. I'm going to tell you all about my configuration process here.

First, Windows uses Eclipse to play C + + for three things:

1. Eclipse

2. CDT (a plugin for developing C + + in Eclipse)

3, Cygwin (Windows Platform UNIX simulation program, including GCC and g++), some people say with MINW, but I chose Cygwin, I think is the same, I chose Cygwin because it is more able to simulate the majority of UNIX commands, but also very convenient.

Eclipse Download and Installation

Eclipse can go directly to the website to download, Google can search the Web site, do not say more. Eclipse is free of installation and is directly available for download. Here's a look at my version:

Second, CDT download and installation

The CDT can download the eclipse directly with the CDT version, or look for updates, downloads, and installations in the Eclipse's Help menu, especially when you are a Java programmer. The Update method is as follows:

1. Open Eclipse, and then:

2. Then enter the following URL in the appropriate place, carriage return, the following appears the updatable software options are all on the hook, as shown:

Http://download.eclipse.org/tools/cdt/releases/indigo

Then click Next, download, OK.

Of course, if you do Android, go directly to Android's official development website to download the Android development version of Eclipse, which is also Eclipse+adt with the CDT.

3. Cygwin Download and installation

Cygwin also directly Google search the official web site to download the installer, open the installer Setup.exe, and then choose Install from the Internet, then choose the location, proxy server, and so on, and finally choose a good download server (the default will choose the fastest server), Go to the Download list, this list is the list of what you want to download, be sure to install the following program, the most annoying is that these prerequisite programs are not installed by default. So, please use the search function to find these programs and then hook yourself up and be sure to install:

1. Search g++ and GCC, and put the corresponding procedures on the hook;

GCC too much, not screenshots, have GCC can hook up on it, better kill the wrong, do not let go.

By the way, I've already installed it, so I can see that the new column in the picture is keep, if it's not installed, it should be a write version number. If you really missed something did not install, when you re-enter this setup, you must choose Keep this option in the upper-right corner, otherwise the default selection of cur will be all the software reinstall again, time will be very long.

2. Search GDB, also check the Devel directory of the program (I have installed, so is the display keep):

3. Search make, also check the debug and devel directory of the program.

Then click Next to download and install the first process a bit long and patiently ...

Third, the configuration

It's time to start configuring it. In fact, the configuration is not very complex, but really need patience in the vast eclipse of the various options to explore slowly. OK, one step at a while.

1. Configure Environment variables

Seemingly open source camp most like to engage in environment variables, Cygwin is no exception, after all, from Linux came to things. Configure the environment variable people should be familiar with, my is Vista system, other systems how to set environment variables can be online Google, not difficult:

Right-click My Computer-> Properties-> advanced environment settings-> environment variables, and then in the system variable inside the path to find the variable, double-click on the original base with Cygwin bin path (note that each path needs to be separated by semicolons). For example, my Cygwin is saved in D:\linux\linux, then the path to the environment variable is D:\linux\linux\bin.

Then click OK, save. Press Ctrl+r and try the following command in the pop-up cmd dialog box to see if it's OK.

Input: Make–v will have make version of the information printed out, the same gcc–v,gdb-v and g++-V also have version information printed out, these no problem, it indicates that the Cygwin configuration is over.

2. Configure Eclipse

First, start Eclipse, click Windows->preferences in the menu, and then tick the options shown in the figure above, which is the PE file that lets Cygwin compile windows:

If there is no binaries error after debugging (set this step is unlikely to appear this problem), then go to the menu project->preferences, tick the following figure in this option:

Then you can create a new project, open Eclipse, and create a new C + + project:

Click Next, and then enter the name of the item and select tool Chain Cygwin

Do not cygwin this tool chain what to do. Then choose other tool chains, the final point finish, the project is generated:

If the previous selection is the other tool chains is not includes this directory, this includes directory how to come out. Right-click the project name, select Properties, and in the dialog box that pops up, choose c + + Build->tool chain Editor:

In the current Toolchain drop-down list, select Cygwin, if the Drop-down list is not Cygwin, the above display compatible tool chain only that tick off, the Drop-down list will appear cygwin. Please ensure that usedtools contains Cygwin C + + compiler and linker, if not included, click the Select Tools button Plus, this operation is intuitive, no screenshots.

Once you've decided to save these options, go back to the main interface, and you'll find the includes directory appear.

Next, click the New button, or right-click the project name, select New, and add a CPP file:

Enter the classic Hello World:

At this point, you can compile the link program by clicking on it:

But this will only compile the link, but will not run, and will not debug the program, but there are no programs found error. Eclipse did not send the Buddha to the west, the good guys do the bottom, we have to manually make a simple configuration:

Go to the Debug Configuration dialog box and select C/c++application->test Debug: (Test is my project name)

Click the Search Project button and in the pop-up dialog box:

Select the exe file you just compiled, and try again:

Hello World has finally printed out:


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.