Windows + GCC + CDT use Eclipse to develop C and C ++

Source: Internet
Author: User

Reproduced from: http://www.javaworld.com.tw/

Author: sungo

In addition to developing Java, eclipse also supports many languages.
The development environment of C and C ++, and then there will be opportunities to introduce others. Enjoy it!

OS: Windows XP Professional SP1
Version: Eclipse 2.1.2

I. First, you need to compile CDT and eclipse 2.1.2 users. Please refer to the following example:
CDT 1.2 full for Windows r2.1.1 1.2.0 Ga-full-Windows.
For eclipse 2.1.3 users, refer to CDT 1.2.1.
For eclipse 3.0 M7 users, refer to CDT 2.0 M7.
For eclipse 3.0 M8 users, refer to CDT 2.0 M8.
For eclipse 3.0 M9 users, refer to CDT 2.0 M9.
Bottom site: http://www.eclipse.org/cdt/

Security: sends the entire features and plugins information after the release to the eclipse security information.
And re-open eclipse.

II. The gnu c, C ++ compiler that can be used in Windows is as follows: mingw.
Download has a long string. Please select this version:
Mingw bin MinGW-3.1.0-1.exe 14863 kb Sep 15,200 3
Bottom site: http://www.mingw.org/download.shtml

Security Engineer: The security engineer selects the C slot, and then takes the next step. After the installation is complete, the path is
-> C:/mingw.

3. In Command Line mode, merge between two rows. First place
Mingw32-make.exe make.exe, because it will be used in Eclipse
Will catch the system make this parameter name rather than the mingw32-make.

(Alias: if you do not change the name or have other make programs, you can also set
In make targets view, when a new task is added, the build command is canceled.
Use default, use mingw32-make) --SnpshuRefresh.

And project properties-> make project-> change make to mingw32-make)
Add the following settings to the environment changes:
PATH: C:/MinGW/bin; (if the system already has other C/C ++ processors, add C:/MinGW/bin to the beginning .)
LIBRARY_PATH: C:/MinGW/lib
C_INCLUDE_PATH: C:/MinGW/include
CPLUS_INCLUDE_PATH: C:/MinGW/include/c ++/3.2.3; C:/MinGW/include/c ++/3.2.3/mingw32;
C:/MinGW/include/c ++/3.2.3/backward; C:/MinGW/include

First, use the text handler to compile the original handler used by zookeeper. The Handler name is main. cpp.
 

#include 
 
using namespace std;

int main(void) {
cout << "Can You Feel My World?" ;

return 0;
}

In Command Line, the explain Command:

C:/g++ main.cpp -O3 -o hello

(The O of O3 is an English large "Uniform ")
After successful renewal: the following line is generated: hello.exe.
The faces of the rows are as follows:

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:/Documents and Settings/sungo> Cd/

C:/> G ++ main. cpp-O3-O hello

C:/> hello
Can you feel my world?
C:/>

Optimized:-O3 flag indicates the maximum latency of the pipeline is optimized, and the maximum latency is the slowest, but the production of the pipeline is optimized.
The number of processed files will be minimal, and the speed of the processed files will be the fastest. The-O flag indicates that the completed *. EXE files will be renamed again.

◎ Step 1. After eclipse is started, start C/C ++ development to use the scenario.
Windows-> open perspective-> C/C ++ Development

◎ Step 2. Establish a case for C ++.
File-New-> Project-> C ++-> standard make C ++ Project
(The subsequent steps are the same as the general Java coding case. You can simply configure them)

◎ Step 3. Import the main. cpp of our program into the project.
File-> Import-> File System-> Program program C:/Main. cpp

◎ Step 4. Create a makefile.
File-> New-> file: makefile. (You do not need to enter a secondary name)

The makefile content is as follows:

all:
g++ main.cpp -g -o run

Note: The makefile sequence layout must use tab sequence as the sequence layout, and cannot use space 4 as the sequence layout,
Otherwise, the Build will have a problem.

◎ Step 5. Set Make Targets.
Windows-Show View-> Make Targets
In the Make Targets window, right-click the mouse and Add Build Target
Name: Invalid parameters. Build Target: all.

◎ Step 6. skip steps.
Click "Make Targets" zhuyun "created in zookeeper and click" 2,
In this case, we have already created hello.exe. Possible
The C-Build outputs window shows the following outputs:

make -k all 
g++ main.cpp -g -o run

◎ Step 7. *. exe configure the parameters before setting. Because it is Run in Windows, you must first set
, Open Project-> Properties-> C/C ++ Make Project-> Binary Parser plane.
Binary Parser drop-down list: Change ELF Parser to PE Windows Parser.

Step 8: Skip the line.
Run-> Run as-> C Local Application.
At the bottom of the consloegion window, you can see the response results of hello.exe.

When the original token has been modified and you want to renew it, as long as the mouse clicks button, we are in step 5.
You can rebuild the created Make Targets "zookeeper.

Appendix:
 

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.