C++ configuration in Eclipse

This tutorial has been written in a Windows XP Professional environment, satisfying the
following requirements:  

  1. Java 2 SDK v1.4.1  
  2.  Eclipse v2.1  
  3. MinGW v3.0.0-1   http://sourceforge.net/projects/mingw/
  4. 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值