Use eclipse CDT to establish a C ++ development environment under Windows

Source: Internet
Author: User
Preface:Recently, many people have asked about how to use CDT in C ++. It can be seen that there are still many mingw users and potential users. I will summarize the usage of this development tool. Through this article, you should be able to learn how to quickly build a C ++ development environment under eclipse.

1. Brief Introduction to CDT (introduced on the official website)

CDT provides the functions required by IDE:

  • C/C ++ Editor (basic functionality, syntax highlighting, code completion etc .)
  • C/C ++ debugger (Apis & default implementation, using GDB)
  • C/C ++ launcher (Apis & default implementation, launches and External Application)
  • Parser
  • Search Engine
  • Content assist provider
  • Makefile Generator
2. Development Environment full backup

CDT is only a front-end for C ++ development. The backend needs to assemble the GCC compiler on its own. To make CDT work normally, the required software packages include

  • Eclipse 3.2.0 (Development Environment carrier)
  • CDT for eclipse 3.2.0 (Development Environment plug-in)
  • Mingw 5.0.0 (compile the debugger)
  • Cygwin or msys (Linux Command Simulation Environment)

Because CDT is a development tool that requires mingw support, sometimes some Linux commands are inevitable. For example, the automatically created MAKEFILE file contains RM commands. In other words, CDT cannot be used for development without the support of the Linux simulated environment.
3. Install mingw and cygwin

As the development backend of CDT, here is a brief introduction to the installation of mingw and cygwin. Both packages are installed on the network. You only need to download the corresponding Installation Wizard on the official website and select the desired or interested installation kits. If it is limited to basic development of C ++, the minimum configuration is recommended:

  • 3.1.mingw
    • In addition to the basic commands required for development, such as GCC, mingw base tools also includes necessary components such as WIN32API.
    • GCC-C ++, mingw C ++ language support.
    • Mingw32-make, This Is A make tool that comes with mingw, CDT will be used when compiling the program
  • 3.2.cygwin
    • Default installation

You can also try msys. However, in the sense of Linux Simulation Environment, cygwin and msys are equivalent, and cygwin provides more comprehensive and richer suites. This article selects the cygwin suite.
Mingw and cygwin do not require any special configuration. To guarantee the installation, check whether the Windows PATH environment variables are correctly added to the bin directory path of mingw and cygwin. If it is not added, add it. In the Windows command line, type:

Gcc

IfGCC: no input filesThe mingw compilation environment has been set up.
Try ls again and type:

Ls

If it works properly, the list of the current folder is displayed. If no problem exists, you can start to configure the CDT development environment.
4. CDT installation and configuration

There is nothing to say about the installation of CDT. You can download the plug-in compressed package from the official site and decompress it to the eclipse folder. Here we will talk about how to use this plug-in.

  • 4.1. Where is the global configuration?

    Click prefrences in the window menu to display the eclipse global configuration dialog box. The CDT configuration is under the C/C ++ tab of this dialog box. Many options can be used by default. You can configure global compilation and make features in the C/C ++> make-> New make projects tab. Pay special attention to the first item under make builder in this tab. We will use mingw as the back-end for compilation, the make tool is also provided by mingw, so to change the default make command to the mingw32-make, other options will look at their preferences.

  • 4. 2. Create a new project

    CDT provides two types of projects: managet make (c | C ++) project and standard make (c | C ++) project. The former automatically generates a make file for automatic compilation, and the latter needs to manually compile a configuration file. Select which one depends on your needs.

  • . Mounting third-party libraries and compiling options

    Third-party libraries are inevitable for software development. CDT has prepared user interfaces to mount these libraries. All the options are in properties (right-click the current project ). The Command Options of compiler and linker under tool settings provide these interfaces. If you want to pre-define some macro, you can specify them in the defined symbols in the preprocesser of the compiler tab. CDT will generate the-dmarcro style parameters.

5. Postscript

Now, a basic available c ++ development environment is ready. However, I personally think that CDT is not very mature. slow running, debugging speed, and limited code prompting are an important reason to restrict it. Unless you have no choice, we recommend that you do not use this plug-in. Even so, this plug-in provides a new tool for us to develop C ++ projects. The programmers who have worked hard for this are worthy of respect.

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.