Sunday, November 05, 2006

Using Eclipse as C++ development platform

Albert Einstein once said, "Two things are infinite: the universe and human stupidity. But I’m not sure about the universe." If only he has been here for a bit more, he would have said "Three things are infinite: the universe, eclipse plugins and human stupidity. But I’m not sure about the universe."

To start developing C and C++ applications on eclipse you need to:
  1. Ofcourse If you're not already an eclipsian (how dare you!) you need to download eclipse SDK.

    Installing Cygwin:
  2. Download cygwin. Cygwin is a UNIX®-like environment for Windows that includes a GCC port, along with all necessary development tools, including automake and the GNU Debugger (GDB). Cygwin is built around the cygwin1.dll library.
  3. When the download is complete, run setup.exe, click next and then 2nd option, download without install.
  4. After choosing a mirror and blabla, make sure you to select the most two important packages, "gcc-g++" and" make".. You will find them under All >> Devel category. Do not skip this step! click next and wait for the download to finish.
  5. Rerun setup.exe, but this time with the 3rd option, install from a local directory.
  6. Now you should have a window with the title "Choose Installation directory"Choose UNIX file type and choose the directory where you want to install cygwin.
  7. Click next, on the window with the title "Select local package directory", select the directory which you have used when downloading in step 4.
  8. Select the packages to install and still make sure to select "gcc-g++" and" make".. You will find them under All >> Devel category. Do not skip this step! click next and wait for the installation to finish.
  9. To check cygwin version open cygwin bash shell cygwin.bat and type "cygcheck -V" you should see
    "cygcheck version 1.43
    System Checker for Cygwin
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
    Compiled on May 25 2004"
  10. To make the tools also available in a dos window add the Cygwin bin directory to your path.
    e.g.: PATH=%PATH%;C:\Tools\cygwin\bin
  11. To verify if the utilities are installed, In a dos window type: g++ --version
    You should see:
    g++ (GCC) 3.3.3 (cygwin special)
    Copyright (C) 2003 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  12. type: make --version
    You should see:
    GNU Make 3.80
    Copyright (C) 2002 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.

    Installing CDT
  13. Open eclipse. Go to Help >> Software updates >> find and install. Select Search for new features and click next.
  14. Create a new remote site with a Name, CDT and URL "http://download.eclipse.org/tools/cdt/releases/callisto".
  15. Select this remote site to search and click next. Proceed as the installer suggests until it's done. It should ask to restart eclipse.
  16. Congrats! Now you can start developing C++, but remains a concrete example.

    Creating a project
  17. To create a new project, go to File >> New >> Project and select C++ >> Standard Make C++ Project. Give it a name and click finish.
  18. Now you can right click the new project in the workspace and New >> File. Give it a name .cpp for example "test.cpp"
  19. Open the file and go on write your C++ program. For example
    #include "iostream"
    using namespace std;


    int main() {
    cout << "This is a demonstration! \n";
    return 0;
    }
  20. Now you need a make file. Right click the project and New >> File. Name it "makefile". Here's a sample makefile:
    CC = g++
    LN = link.exe
    EXENAME = test

    all: $(EXENAME).exe
    [tab]@echo ********************************
    [tab]@cmd /c $(EXENAME)
    $(EXENAME).exe: $(EXENAME).o
    [tab]$(CC) -o $(EXENAME).exe $(EXENAME).o
    $(EXENAME).o: $(EXENAME).cpp
    [tab]$(CC) -c $(EXENAME).cpp
    clean:
    [tab]rm $(EXENAME).exe
    [tab]rm *.obj
  21. Please note you need to change the EXENAME to match your .cpp file. And also replace the [tab] with an actual tab not spaces!
  22. Now right click the project and then "Build project". Voilaaa!
Happy Eclipsing !

--
"I pretended to be somebody I wanted to be until finally I became that person. Or he became me." - Cary Grant

13 comments:

Hussein Aman-Allah said...

Thxx Sub ;)

Unknown said...

Aman: THANKS! for such precise instructions. My colleagues and I had been breaking our heads from quite some time trying to get the output of a program to display on the Eclipse console. And it turned out to be just a path problem which got fixed by your step 10.

Unknown said...

BTW, as a side note. For those who dont want to bugger about with Eclipse and Cygwin/minGW as seperate installations, I suggest installing Wascana Desktop Developer, found here: http://wascana.sourceforge.net/

Its a completely standalone, Eclipse-based C++ development environment. Comes with MinGW toolchain, and can easily be configured to use Cygwin.

Anonymous said...

Hey,

I am regular visitor of this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]You have really contiributed very good info here wikimix.blogspot.com. I am sure due to busy scedules we really do not get time to care about our health. Let me show you one truth. Research shows that about 90% of all United States grownups are either obese or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these citizens, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? You can easily lose with with little effort. Some improvement in of daily activity can help us in losing weight quickly.

About me: I am writer of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for fast weight loss.

Anonymous said...

K. BUHLER- considera ca, copilul se joaca doar pentru placerea pe custody o simte in timpul jocului, cold de rezultatul lui.http://www.jocuricamioane.net

Anonymous said...

The foremost half of our life is ruined nigh our parents and the in the second place half next to our children. Clarence Darrow

Anonymous said...

Interesting poop, may I utter a interest of it in my website?

Anonymous said...

Teoria catardica se intemeiaza pe concept ca jocul constituie un mijloc de innobilare a unor instincte inascute. Prin jocurile de fictiune, de achizitie, de constructie, copilul va anticipa viitoare sa viata de full-grown, folosind mijloacele de dolour dispune si in limitele impuse de mediu.Jocurile copiilor si, secret, ale adultilor contribuie la formarea si dezvoltarea personalitatii.

Meera said...

I have written an entire book on this topic. See http://eclipsebook.in/

I hope it turns out to be helpful to you readers. The HTML edition of the book and a preview copy are available for free... :-)

Anonymous said...

Superb post however , I was wondering if you could write a litte more on this topic?
I'd be very thankful if you could elaborate a little bit further. Thank you!

Here is my site; Nuvo Cleanse

Anonymous said...

Hey There. I discovered your weblog using msn.
That is a really neatly written article. I will be sure to bookmark it
and come back to read more of your helpful information.
Thank you for the post. I will definitely comeback.


Review my webpage ... Green coffee

Anonymous said...

You really make it appear really easy with your presentation however I to find this topic to be actually something which I believe I would by no means understand.

It seems too complicated and very large for me. I'm looking ahead on your next put up, I'll attempt to get the hold of it!


testostrong

Anonymous said...

Hey there just wanted to give you a quick heads up.
The text in your article seem to be running off the screen in Opera.
I'm not sure if this is a formatting issue or something to do with web browser compatibility but I thought I'd
post to let you know. The style and design look great though!
Hope you get the problem fixed soon. Many thanks

Check out my weblog; Acai ENergize