This tutorial has been written in a Windows XP Professional environment, satisfying the
following requirements:
- Java 2 SDK v1.4.1
- Eclipse v2.1
- MinGW v3.0.0-1 http://sourceforge.net/projects/mingw/
- CDT v1.1.0 GA http://www.eclipse.org/cdt/
Installing and Setting Up MinGW:
1.Install MinGW to the following directory: C:/MinGW/
2.Assuming that MinGW has been installed to C:/MinGW, add the
following to the end of the Variable value:
;C:/MinGW/bin
3.To verify that the installation of MinGW is successful and that the PATH variable has
been changed correctly, perform the following steps:
a. Click on Start Run !-
b. Type cmd into the dialog box and press OK.
c. Type the following into the command prompt and then press ENTER:
gcc -v
Installing the Eclipse CDT Plugin:
Once the download is complete, unzip the contents of the file
org.eclipse.cdt-win32_1.1.0.bin.dist.zip
to the directory where Eclipse.exe is located. For example:
C:/eclipse-SDK-2.1-win32/eclipse
Creating a C++ Project using the Eclipse CDT Plugin:
1.Create a Standard Make C++ Project.
2.Click on the Build Settings tab and under the Build Command section:
a. Uncheck the Use Default checkbox.
b. Enter the following in the Build Command field (note that mingw32-make
is one string, with no embedded blanks; also, the complete path the the
mingw32-make command may be specified):
mingw32-make -f makefile
c. Click Finish to continue.
3.create a cpp project named main.cpp
4.create a make file named makefile as following:
main : main.o
g++ -o main main.o -L
main.o : main.cpp
g++ -ggdb -c main.cpp
all :
${MAKE} main
clean :
-del main.o
Notes: The command must be preceded by a TAB and end with a Return.
5.We are almost done! Now to run your application:
a. Click on Run ->Run!
b. In the Configurations window, click on C/C++ Local, and then the New
button.
c. In the Name field, type your project name such as HelloWorldCpp.
d. In the C/C++ Application field, type main.exe.
e. The settings on the other tabs will be sufficient for the purpose of this
tutorial.
f. Then click on the Apply button. then run it.
FAQ:
1.Why my makefile has errors?
==>The command must be preceded by a TAB and end with a Return.
2.Why my main.cpp file has errors?
==> In main.cpp, add the following line right #include <iostream>:
using namespace std;
3.When I build it, errors ocurred"Error launching builder (mingw33-make -f makefile all )
(Exec error:Launching failed)"?
==>Make sure your have installed the "make" function modules,you can reinstall your Mingw to resolve it!
4.When fill in the ".exe" file name in the "C/C++ Application" field in "run..",it hints error"Program is not a recongnized executable".
==>Open the project "property" ->"C/C++ Make Project" ->"Binary Parser" ,make the "PE Windows Parser" checked.