WINDOW GCC CDT Develops C, C with Eclipse
Reprinted from: http://www.javaworld.com.tw/
Author: SungoeClipse In addition to developing Java, AUNGOECLIPS has supported many languages, now introduces C, C development environment setting, and later introduces other. Enjoy it! OS: Windows XP Professional SP1 User Versions: Eclipse 2.1.2 One. First To download CDT, Eclipse 2.1.2 users, please download this: CDT 1.2.0 Ga - Full - Windows. Eclipse 2.1.3 Users please download: CDT 1.2.1. Eclipse 3.0 M7 users please download: CDT 2.0 m7. Eclipse 3.0 M8 User Please download: CDT 2.0 M8. Eclipse 3.0 M9 users please download: CDT 2.0 m9. Download URL: http://www.eclipse.org/CDT/ Installation: Send the complex Features, Plugins The entire data clip is copied into the Eclipse installation data, re-opening Eclipse. Downloading the GNU C, C compiler that can be used on Windows, here to download: mingw. Download a long string, please select this version: mingw bin mingw-3.1.0-1.exe 14863 KB Sep 15, 2003 11:14 Download URL: http://www.mingw.org/download.shtml Installation : Install the directory option C slot, then the next step (Next) is OK. The post-installation path is like this -> c: / mingw. I. First test compilation and execution in Command Line mode. Create MINGW32-Make.exe under C: / MingW / BIN, because it will preset this file name instead of MINGW32-Make when using Eclipse. (Note: If you do not rename or have other Make programs, you can also add a Targets View where you will add a TASK. When you add a TASK, build Command cancels Use DEFAULT, using mingw32-make) - - Supplement by snpshu. And Project Properties-> make Project -> Change Make to MINGW32-MAKE Add: PATH: C: / MingW / BIN; (If the system already has other C / C compiler, please put C : / Mingw / bin is the front.) Library_path: c: / mingw / libc_include_path: c: / mingw / incrudecplus_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 the original file used by the text editor, the file name: main.cpp.
#include
Using namespace std;
INT main (void) {
COUT << "Can you feel my world?"; return 0;
}
Compile instructions under Command Line:
C: / g main.cpp -o3 -o hello
(O3 O is English capital "Europe") After successful compilation: will generate Hello.exe execution files. The execution screen is 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 Helloc: /> Hellocan you feel my WORLD? C: />
Note: The -O3 flag indicates the highest level compilation optimization, the compilation speed is slower, but the resulting executive file will be the fastest, the speed will be the fastest; the -o flag indicates that the compiled * .exe renamed. ◎ Step. After opening Eclipse, first turn on the C / C dedicated view. Windows-> Open Perspective-> C / C Development ◎ Step II. Create a project for C . FILE-New-> Project-> C -> Standard Make C Project (The next steps are the same as the establishment of a general Java project) ◎ Step three. Put the main.cpp import we have just written, Add it in the project. File-> import-> file system-> Browse C: /main.cpp ◎ Step 4. Create a Makefile. File-> new-> file, file name fill in: makefile. (Do not need to play the secondary file) makefile content as follows:
All: g main.cpp -g -o run
Note: Makefile replaces the rearrangement by the Tab key, and cannot be rolled in space 4, otherwise Build will have problems. ◎ Step 5. Set the Make Targets. Windows-show view-> make targets Press the Make Targets window to right-click, Add Build Target, Name Type: Compile. Build Target hits: ALL. ◎ Step six. Compile. When you have just built Make Targets, you will start compiling, and we can find that hello.exe has been generated under our project. The following output results can be seen under the bottom C-Build window:
Make -k all g main.cpp -g -o run
◎ Step 7. *. EXE is set before execution. Because running under Windows, you must make a setting first, please open the Project-> Properties-> C / C make Project-> Binary Parser page. Binary Parser pull-down menu, change Elf Parser to PE Windows Parser. ◎ Step 8. Execute. Run-> Run as-> c local applications. See the execution result of Hello.exe under the CONSLOE window under the bottom. Note: When the original file has a modification, when you want to recompile, as long as the mouse double-clicks "Compilation", you can Rebuilding. Drawings: