Using Eclipse to build a C + + development environment under Windows __c++

Source: Internet
Author: User
Tags bz2 gdb debugger
There are a lot of Windows C + + IDE, to learn about eclipse, so choose the following eclipse + GNU toolchain (the word toolchain is very vivid).

1. First download eclipse for C + +, the latest version is based on Eclipse 3.5.1, called Galileo (Galileo), last version 3.4 is called Ganymede (Ganymede). Download Address: http://eclipse.org/downloads/, select 32bit for Windows, file name Eclipse-cpp-galileo-sr1-win32.zip



2. Decompression, direct operation. Note that at least the JDK you have installed (I am using JDK1.6). After running a gray-blue welcome page appears, into the tutorials. It's a good habit to read tutorial first.

3. First understand what is the CDT, is C/s + + Development Toolkit,bulabula ... And then it says, "This thing doesn't contain C + + compiler, debugger, you have to do it yourself."

4. Keep looking. Under Windows, MinGW and Cygwin are the 2 main ways to get the GNU Toolchain (GNU Toolchain,gnu A series of toolkits, which I understand mainly as a series of tools for GCC). The biggest difference is that MinGW uses Windows C's runtime, called MSCVRT, and Cygwin uses a set of GPL-based DLLs (the GPL protocol is contagious, and what you develop yourself after using the GPL protocol is also subject to the GPL protocol), So MinGW avoided the GPL protocol.

5. MinGW and CDT can be well integrated. Well, we're loading MinGW (MinGW is minimal GNU for Windows, this download process is pretty slow, I've been down for half an hour). The current version is Mingw-5.1.6.exe, I have a brain to a full install. After the installation, we found that: do not install the "MinGW make feature as the" Msys version of Make "from" Step 5 are a more complete implementation of make. (Do not install MinGW, step 5th Msys is a better solution)

6. In order to avoid problems that may be encountered in the future, reload. Here is the complete installation step:
1) Download MinGW, address http://sourceforge.net/projects/mingw/files/
2 Install the MinGW Base tool and the g++ compiler (do not install make); I've got an ADA compiler in there, and I've installed everything except made.


3 The current version (it refers to MinGW-5.1.3, but I do not have the same 5.1.6) did not install GDB debugger, download it: http://downloads.sourceforge.net/mingw/gdb-6.6.tar.bz2
4 decompression gdb-6.6.tar.bz2 to you to install MinGW place, GDB-6.6/also has a series of Bin,inclue folder, directly to MinGW under the cover can be
5 If you want to use makefile, please download Msys-1.0.10.exe,msys is a implementation of make and command line. Well, it needs to be used. Download Address Http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe
The installation interface is a command interface, write 2 "y" and then tell the MinGW installation path.


OK, the installation section is complete. Here are 2 small examples.

7. First create a simple HelloWorld C + + project, this is very simple, press the wizard Wizard to build a template.


Run when you choose Run configurations, and then double-click the C + + application to build a new run configuration on the line.


8. A makefile type of project is built below. Select new C + + Project-> Makefile Project-> Empty Project, we build an empty project, There's nothing in there (except 2. project files), at which point we build a source file and a make file: Main.cpp and Makefile, as follows, are built into the root directory:

C + + code   /*   * main.cpp   */      #include  <iostream >   using namespace std;      int main  ()  {       // Say Hello five times       for   (int index = 0; index < 5; ++index)           cout <<  "helloworld!"  << endl;       char input =  ' i ';       cout <<  "to exit, press  ' m '"  << endl;        while (input !=  ' m ')  {            cin  >> input;            cout <<  "YOU&NBSP;JUST&NBSP;ENTERED&NBSP; "  << input                 <<  " you need to enter m to exit."  << endl;       }       exit (0);   }  
Makefile Code all:hello.exe clean:rm main.o hello.exe hello.exe:main.o g++-g-o Hello MAIN.O main.o:g++-c-g main.cpp
Note that the beginning indent in the Makefile is tab rather than space. If compile-time prompt No separator ... There is a problem here.

9. Ok, selected project, dot build (or point that little hammer), you will find this error: (Cannot run Program "makes": Launching failed), Ah, our make.exe is not yet set. Select the project, direct alt-enter to the Engineering Properties page, add Msys bin to path.


10. Rebuild, done.
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.