1. Environment installation and configuration
First, you must download the software and plug-ins.
(1) JDK (jdk6)
(2) eclipse (1, 3.6)
(3) CDT plug-in (cdt-master-7.0.2)
(4) mingw Compiler (I use mingw 5.1.6)
The second step is environment configuration.ProgramJDK environment variable configuration should be very familiar, mainly introduce mingw configuration.
1. Install mingw 5.1.6
First download and then double-click the installation process as follows:
In this step, if you only want to compile C ++/C programs using eclipse, select the above three items. Of course, you can install them. Next, let's wait for the download and installation. If your network speed is fast, you are very lucky.
2. mingw environment variable settings
This article also describes a lot of things on the Internet. It is mainly about setting the PATH variable (assuming that mingw is installed in the D:/mingw/bin directory). The settings are as follows:
Mingw_home = D:/mingw
LIBRARY_PATH = % mingw_home %/lib
C_include_path = % mingw_home %/include
Cplus_include_path = % c_include_path %/C ++/3.4.5; % c_include_path %/C ++/3.4.5/mingw32; % c_include_path %/C ++/3.4.5/backward; % c_include_path %
Add % mingw_home %/bin at the end of path.
Copy the mingw32-make.exefile in D:/mingw/bincatalog (later renamed make.exe.
In this case, you can run the make -- version command in the console. If the make version information is displayed, the setting is successful.
Ii. compile C ++ in eclipse (eclipse 3.6)
Again stressed: Because the eclipse default file for compilation is make.exe but mingw after installation make file name is mingw32-make.exe so you need to change the mingw32-make to make!
To enable CDT to compile with mingw, you must set WINDOW> preferences> C/C ++> New CDT Project Wizard in eclipse.
Select mingw and select mingw as the default compiler.
Window-> preferences-> C/C ++-> New CDT Project Wizard-> binary parsers under makefile project selects PE windows parsers.
1. Create a C ++ Project
File-New-> Project-> C ++ Project
Enter the project name to be created step by step. The CPP file (assuming helloworld. cpp) can be as follows:
# Include <iostream>
Using namespace STD;
Int main ()
{
Cout <"Hello world! "<Endl;
Return 0;
}
2. Create a makefile. File-> New-> file. Set the file name to makefile. (Extension not required) The makefile content is as follows:
All: G ++ helloworld. CPP-g-o run
Note: you must use the tab key to scale down the makefile, instead of Space 4. Otherwise, the build may fail.
3. Set make targets. Windows-show view-> make targets right-click the make targets window and add build target and name to compile. Build target: All.
4. compile. In the just-created make targets "Compilation", click the mouse 2 to start compilation. Then, we can find that hello.exe has been generated in our project. You can view the output result in the bottom window, and then compile it successfully. You will find that there is an additional binariesdirectory under the project file, which contains the .exe file. The. exe file is also available under debug. However, the following error occurs:
G ++-O0-G3-wall-C-fmessage-length = 0-osrc/hello. O .. /src/hello. CPP
internal builder: cannot run program "G ++ ":????????? ¡§?
build error occurred, build is stopped
time consumed: 0 ms.
after checking for a long time and trying for a long time, you can exclude this error by setting Org. eclipse. CDT. core. decompress win32_5.0.0.200902130801.jar to a folder. Do not forget to delete the original jar package.
double-click "compile.
5. run
after compilation, generate the EXE executable file, which may not be running yet. Click the lower triangle icon next to the eclipse running button, which has run commands, as shown in, double-click C/C ++ local application to create a file named "your project name + debug. Click to enter and select debug and run under the common option ).