Configure and use eclipse CDT 3.10 in Windows

Source: Internet
Author: User
Since CDT is just a front-end Editor, We need to configure the compiler environment before we start. In addition, because CDT does not have built-in formatter, artistic style is also required as formatter (for C, C ++, C #, and Java source code ). Note that the focus of this article is the configuration of CDT, So assume that your eclipse 3.20 has been correctly installed and configured.

1. Configure the Compiler
Considering that we need a complete set of environments such as compilers and debuggers, cygwin and mingw are good choices. Cygwin is a UNIX-like environment for windows. It includes GCC porting and all necessary development tools, including automake and GNU Debugger (GNU Debugger, GDB ). The alternative solution for cygwin is minimalist GNU for Windows (mingw). This tool is a set of Windows-specific header files that can be freely obtained and distributed for free and imported to the database, these header files and imported libraries are combined with the GNU tool set (which allows you to generate local Windows programs that do not depend on any third-party DLL.
Here mingw is selected. Download the installation file for Windows on SourceForge (version 5.03 at the time of writing this article ).
After the download is complete, select download and install. When you ask which mingw package do you which to install? Select current, and then select the components to be installed (at least mingw base tools, G ++ compiler, mingw make). Wait a moment until the installation of the entire compilation and debugging environment is complete, it is very convenient.
We need to set the environment variables as follows (assuming that mingw is installed on D:/mingw ):
Mingw_home = D:/mingw
Classpath =.; % mingw_home %/lib
Path =.; % mingw_home %/bin

When running GCC in cmd, the prompt "GCC: no input files" should be displayed. This indicates that the environment variable is set correctly. Otherwise, check the setting.

2. CDT Installation
For CDT installation, you only need to find the correct version number. Currently, the corresponding eclipse3.20 CDT version is 3.10. After the download is complete, decompress it to the eclipse directory to overwrite the original plungins and features directories. For cdt3.10, select windows.

3. Configure Artistic Style
Although you can see a formatter option on the CDT configuration interface, nothing can be selected. It is estimated that it is not yet completed. Therefore, we can only use a third-party formatter to format the code. The astyle.exe file can be decompressed to any directory (for example, D:/astyle ).
Open eclipse and choose run> external tools> new lunch configuration.
On this page, enter the following configurations:
Name = formatter (optional)
Localtion = D:/astyle/astyle.exe (based on the directory for extracting astyle)
Working directory =$ {workspace_loc:/$ {project_name} (working directory, directory of the current project under workspace)
Arguments = -- style = Kr -- mode = c -- indent = tab $ {resource_name} (specify the formatting mode, indentation, and file name of the Code. For details, see options)

Now, the configuration is ready. Let's try a new project.
Create a managed C ++ project, and then create a source file named helloworld. cpp.
Try the following Hello world code/* helloworld. cpp */
# Include <iostream>

Using namespace STD;

Int main (){
Char STR [100] = "Hello world !! ";
Cout <STR <Endl;
}

At this point, the reader may have discovered that the Code cannot run, which is good. To complete compilation properly, the simplest way is to copy the mingw32-make.exeunder mingw/bind in the same directory and rename it make.exe. In this case, run as C/C ++ local application to complete compilation and linking and execute the output.
Note: We didn't write makefile, because the managed C ++ project we created has done everything for us, which is convenient!

Finally, I found that the indexing problem still exists in this version. For more information, see my other blog.

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.