Eclipse: Importing an existing project

Programming, for all ages and all languages.
Post Reply
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Eclipse: Importing an existing project

Post by Solar »

I repeatedly considered doing my development work in Eclipse, using the CDT C/C++ plugin. However, I utterly failed in getting the idea of how to integrate an existing build system (i.e., Makefile, or even autoconf / automake) properly imported, so I could trigger builds from within Eclipse. Tutorials I found on the web were always like, "it's so easy, just click here and here and there you are", but I always ended up with nothing more but the source files in the Navigator, and scratching my head how to get to my Makefile targets (or my ./configure / make) to where they belong (the "Makefile Targets" tab?).

I simply couldn't figure out how that tab worked...

Can anybody shed some light on this?
Every good solution is obvious once you've found it.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: Eclipse: Importing an existing project

Post by frank »

Two things to start off with, make sure it's a C/C++ project and that you are in the C/C++ perspective. From there I can right click on the project name in the navigator and go to the C/C++ Make projects tab to change the make preferences. Then I can go to the projects menu on the main program and press Rebuild All to build the project.

Also try manually setting the path to the compiler and linker in the Make tab, it wasn't importing the default path correctly for me, that setting is in the Environment tab within the C/C++ Make projects tab.

One additional thing, the folder I set as my workspace directory actually contains my source files. I don't think that's the way it is supposed to be but it works for me.

I hope you can get everything working because to me personally Eclipse is one of the best IDEs for C.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Eclipse: Importing an existing project

Post by Solar »

Oops, I forgot I asked that here...

I found out why it didn't work for me. (Should've posted it here.)

Yes, if your top-level directory contains a Makefile and all you want is target "all", everything's OK out of the box. But for my projects, that isn't the case. I found out that you have to create the desired make targets in the "Make Targets" tab, in the directory the Makefile is residing in. Then you can trigger the target by double-clicking it.

Now, I have to find out how to run ./configure with the proper parameters, automatically, from within Eclipse... ;-)
Every good solution is obvious once you've found it.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: Eclipse: Importing an existing project

Post by frank »

If your ./configure options are constant then you could try setting up another Make Target and changing the build command. If the options are different then you could try to make a script that figures out the proper options and then set that as the build command.

EDIT: Do you need to run ./configure before every build? Maybe you could try changing the build options in the project menu to run configure then make.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Eclipse: Importing an existing project

Post by Solar »

No, the options are constant (per platform). Thanks for the hint with the build options.
Every good solution is obvious once you've found it.
Post Reply