Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Using Eclipse with an already existing C/C++ project
Using Eclipse with an already existing C/C++ project [message #210392] Mon, 25 February 2008 18:16 Go to next message
Eclipse UserFriend
Originally posted by: ronbbnd.gmail.com

Dear Newsgroup,
I enclose two mails I have sent to the CDT mail list, as I thought that
was the mailing list for CDT related questions.
I have been referred to this newsgroup, so I post my questions here,
hoping that some of you can help me. Thanks in advacne.

The mails follow below:


=======
Mail #1
=======

On Sun, Feb 24, 2008 at 9:23 PM, Ron B <ronbbnd@gmail.com> wrote:

Hi List,

I have recently joined a (linux) project, which has a complete directory
structure, and makefiles.
My objective is to work on the current project tree, as will be somewhat
detailed below, from within the eclipse.
For this, I opened a new project, using the root directory of my project
tree.

The project has currently been developed with other Linux tools such as vi
and emacs, and is roughly consisted of this directory structure:
1. $APP/ - This directory contains most of the components of the
system. Each component has its own makefile in its build list, however,
the entire application's
makefile is given in another directory - $INF
2. $INF/ - the directory contains the makefile and a lot of other
makefiles (all are created by using qmake). It is a pretty complicated
build.

In the existing environment I have no problem of editing files, building
components, and building the entire application.

However, when I tried to create an eclipse project, things got really
complicated for me.
At the moment, all I could do is to create a new project with the $APP
folder, as I described above.

However, I had the following problems:
1. I could not use the makefile in the $INF directory. I would like to be
able to use this makefile, and have Eclipse somehow recongize
the include paths (i.e. -I )- so that the indexer could recognize header
files which are included in the <someFile.hxx> form.

2. Code browsing - Having the ability to open every include file, or every
definition with a single F3 click
This is a clarification for the problem listed in one. If there is some
sort of work around, that does not include a sisyphean copy-paste work,
I would like to know how I can do it.

3. Being able to run a qmake command prior to the make command - and
having the option to turn off the qmake option.
In my environment, a qmake is first invoked to create the makefiles.

4. For some reason I could not use environment variables such as $APP,
but had to use a full name (such as /user/ronb/views/ ..... ) . This could
be problematic, becasue
the files are under source control (clear case), which means that if I
want to use the Eclipse project on another computer, I will have to
re-create it.
Is there any way to work around this?

I have been searching the mailing lists for solutions but couldn't find
them, so I hope you can help me with that.

I would like to emphasis that keeping the current directory structure, and
using the current makefile is of main importance, and is a showstopper for
the immigration to eclipse.

Thanks,
Ron.



=======
Mail #2
=======

I managed to work around the build and qmake problems using ANT build.
(if there's another, elegant way I would love to hear so).

However, I still cannot get my files indexed. Namely, I get messages of
type "Could not find symbol SomeSymbol in index".
Can someone please help me in doing it?
I understand that Eclipse has the ability of generating the index
according to the build results.

I built the application with the ANT builder. The build output was shown
in the Eclipse console, but I did not get any indexing done.

My build.xml file looks like this:


<?xml version="1.0"?>
<project name="MyAppBuild" default="make">
<description>
Ant adaptor for Makefile - first try - RM, February 2008.
</description>

<target name="make" description="build MyApp">
<exec executable="make">
</exec>
</target>

<target name="qmake" description="qmake from start and make clean">
<exec executable="/home/myPath/reQmake.sh">
</exec>
</target>

<target name="clean" description="clean build">
<exec executable="make">
<arg value="clean"/>
</exec>
</target>
</project>
Re: Using Eclipse with an already existing C/C++ project [message #210418 is a reply to message #210392] Mon, 25 February 2008 20:11 Go to previous messageGo to next message
Nick Schweyer is currently offline Nick SchweyerFriend
Messages: 175
Registered: July 2009
Senior Member
Ron wrote:

> 1. I could not use the makefile in the $INF directory. I would like to be
> able to use this makefile, and have Eclipse somehow recongize
> the include paths (i.e. -I )- so that the indexer could recognize header
> files which are included in the <someFile.hxx> form.

> 2. Code browsing - Having the ability to open every include file, or every
> definition with a single F3 click
> This is a clarification for the problem listed in one. If there is some
> sort of work around, that does not include a sisyphean copy-paste work,
> I would like to know how I can do it.

> 3. Being able to run a qmake command prior to the make command - and
> having the option to turn off the qmake option.
> In my environment, a qmake is first invoked to create the makefiles.

> 4. For some reason I could not use environment variables such as $APP,
> but had to use a full name (such as /user/ronb/views/ ..... ) . This could
> be problematic, becasue
> the files are under source control (clear case), which means that if I
> want to use the Eclipse project on another computer, I will have to
> re-create it.
> Is there any way to work around this?

> I have been searching the mailing lists for solutions but couldn't find
> them, so I hope you can help me with that.

> I would like to emphasis that keeping the current directory structure, and
> using the current makefile is of main importance, and is a showstopper for
> the immigration to eclipse.

> However, I still cannot get my files indexed. Namely, I get messages of
> type "Could not find symbol SomeSymbol in index".
> Can someone please help me in doing it?
> I understand that Eclipse has the ability of generating the index
> according to the build results.

hi,

there are some specifics in your question, but my first idea is to import
the old project (file/import). Then the indexer knows the directory
structure an can do indexing.

I am not sure if the other questions will be successfully answered with
the import alone. At least you should check the include paths within
"properties" of the project (right click on the project, then select
properties, then C/C++ Include Paths & Symbols).

In my installation of Eclipse I included "qmake" into external tools. So I
have the choice when to use qmake.

I have no idea how to manage cooperation with clear case.

Nikosch


Niko

Eclipse-CDT Version: 2019-12 (4.14.0), Win10 64bit
Re: Using Eclipse with an already existing C/C++ project [message #210426 is a reply to message #210418] Mon, 25 February 2008 22:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ronbbnd.gmail.com

Nikosch wrote:

> hi,

> there are some specifics in your question, but my first idea is to import
> the old project (file/import). Then the indexer knows the directory
> structure an can do indexing.

> I am not sure if the other questions will be successfully answered with
> the import alone. At least you should check the include paths within
> "properties" of the project (right click on the project, then select
> properties, then C/C++ Include Paths & Symbols).

> In my installation of Eclipse I included "qmake" into external tools. So I
> have the choice when to use qmake.

> I have no idea how to manage cooperation with clear case.

> Nikosch

Let us leave clear case aside for the discussion. I stated it because it
implies that working not within the directory structure is unacceptable.
The problem with import is that it copies the entire directory structure,
so I do not work anymore on the project, and would have to copy the files
I work on every time, which is error prone.

Regarding the indexing solution:
Both "import filesystem" and "new project - and specifying the root
folder" result in a partial indexing.
Namely,
#include "someHeader.h" directives are indexed, and can be traversed.
However, #include <bracketHeader.h> will not be indexed, nor resolved.

Another issue is that the makefile for the entire project does not reside
within the imported directory tree. I guess I can work around this using a
custom ant build, or maybe another makefile, but this will still not solve
the indexing problems.
(By the way, I am not proficient with makefiles - how can I make the
makefile run from a different working directory?)
Re: Using Eclipse with an already existing C/C++ project [message #210442 is a reply to message #210426] Tue, 26 February 2008 04:38 Go to previous messageGo to next message
Henning Riedel is currently offline Henning RiedelFriend
Messages: 310
Registered: July 2009
Senior Member
Apparently, you have an external project, with external makefile.

I'm not sure how many ways there are to write and call a makefile/<bunch
of makefiles forming a build env>, but there are a lot. That's also the
reason, CDT is not parsing Makefiles written outside and therefore also
has no clue of includes defined in the makefile.

What you could do:
Create an empty C Project. Add a new folder and select 'Advanced >>' to
create a linked resource. Add the $APP/ as external resource and e.g.
name the folder APP. Then create a second folder the same way using INF
as name and $INF/ as linked directory. But(!), I'm not sure if using
$APP (instead of explicitly using the abs. path) works. Maybe by using
the 'Project Settings'->'C/C++ Build'->'Environment' or 'Variables'.
Could someone of the CDT enlighten me on the difference, and when to use
which.

Then go to 'Project Settings'->'C/C++ General'->'Paths and symbols' and
add each include path by adding 'Workspace path'.
E.g. if you have

dir1/xyz.c
dir1/xyz.h
dir2/abc.c
dir2/abc.h

and xyz.c includes like:
#include "xyz.h"
#include "abc.h"

and abc.c includes like:
#include "xyz.h"
#include "abc.h"

then the indexer will maybe find for xyz.c xyz.h, but not abc.h
and for abc.c will find abc.h, but not xyz.h.

And adding these paths is now the tedious part, because currently, you
can not add more than one path at a time.

Building should work the same, I guess, by setting the make command in
the project settings, the build path to workspace INF resource.

What I would ask CDT team is, how to add include paths as a group to
'paths and symbols'. Maybe something like in the 'Import...'->'from
Filesystem' by setting a root path and selecting each dir by selection box.

Regards,...

Ron schrieb:
> Nikosch wrote:
>
>> hi,
>
>> there are some specifics in your question, but my first idea is to
>> import the old project (file/import). Then the indexer knows the
>> directory structure an can do indexing.
>
>> I am not sure if the other questions will be successfully answered
>> with the import alone. At least you should check the include paths
>> within "properties" of the project (right click on the project, then
>> select properties, then C/C++ Include Paths & Symbols).
>
>> In my installation of Eclipse I included "qmake" into external tools.
>> So I have the choice when to use qmake.
>
>> I have no idea how to manage cooperation with clear case.
>
>> Nikosch
>
> Let us leave clear case aside for the discussion. I stated it because it
> implies that working not within the directory structure is unacceptable.
> The problem with import is that it copies the entire directory
> structure, so I do not work anymore on the project, and would have to
> copy the files I work on every time, which is error prone.
>
> Regarding the indexing solution: Both "import filesystem" and "new
> project - and specifying the root folder" result in a partial indexing.
> Namely, #include "someHeader.h" directives are indexed, and can be
> traversed.
> However, #include <bracketHeader.h> will not be indexed, nor resolved.
>
> Another issue is that the makefile for the entire project does not
> reside within the imported directory tree. I guess I can work around
> this using a custom ant build, or maybe another makefile, but this will
> still not solve the indexing problems.
> (By the way, I am not proficient with makefiles - how can I make the
> makefile run from a different working directory?)
>
Re: Using Eclipse with an already existing C/C++ project [message #210480 is a reply to message #210442] Tue, 26 February 2008 08:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ronbbnd.gmail.com

So I understand that there is NO WAY for eclipse to observe the build
results of an external makefile, and getting the include paths
automatically.
That is exactly what I need at the moment, because I work around the rest
of the problems (except for opening the include file directly), by
creating a new project with the additional source tree, and making a
reference to it from my project.

By the way, if I add a reference to the project - what are the
implications? What can it affect? Can my build be affected in any way,
even though I use an external makefile? (it's hard to believe, but I'm
asking just in case)

That would be a feature I would expect to be in the CDT as it shouldn't be
too complicated, probably just some grep -I [fileList] kind of work.
Re: Using Eclipse with an already existing C/C++ project [message #210485 is a reply to message #210426] Tue, 26 February 2008 08:24 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Ron wrote:
> The problem with import is that it copies the entire directory structure,
> so I do not work anymore on the project, and would have to copy the files
> I work on every time, which is error prone.

It is not necessary to copy your source files into the workspace. If you
have an existing source tree you should do the following:
1) create a new C/C++ project in Eclipse with New->Project->C/C++
2) in the appearing project wizard *unselect* "Use default location" and
choose the location of your existing source tree with the browse button
3) select "Makefile project" (Linux gcc toolchain or whatever you are
using) then click Finish
You have now a C/C++ project that resides in your source tree (.project
and .cproject files are stored there).

The indexer should now partially work. To get better indexer results it is
necessary to build the project. Eclipse will scan then the output (object
files) and select the correct include paths by itself (see your problem
with #include <bracketHeader.h>).

> Another issue is that the makefile for the entire project does not reside
> within the imported directory tree. I guess I can work around this using a
> custom ant build, or maybe another makefile, but this will still not solve
> the indexing problems.
> (By the way, I am not proficient with makefiles - how can I make the
> makefile run from a different working directory?)

1) Open the properties dialog of your newly created project (right click
in the navigator or project explorer view on the project).
2) Go to C/C++ build, there you can choose your "Build command" (make -f
YOUR_MAKEFILE). You can use different Eclipse variables to select a file
outside of your workspace (click "Variables.." and see yourself). Probably
you have to define the "Build directory" as well.

If your compiled object files and linked executable reside outside of your
source tree (out-of-source build). In this case you will need a linked
folder to the output directory and set the output location correctly o
Eclipse can see and scan the output:
1) Project properties->C/C++ General->Path and Symbols->Output location
2) Click "Create / link folder"
3) Click Advanced and select "Link to folder in the file system"
4) Browse your file system or select a variable (you can define variables
for linked folders in the general preferences dialog Windows->Preferences:
General->Workspace->Linked Resources)

I hope this helps.

Axel


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Using Eclipse with an already existing C/C++ project [message #210546 is a reply to message #210480] Tue, 26 February 2008 14:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kristofer.hansson.gmail.com

Hi Ron

I have thought of the same thing, came up with a possible solution, just
haven't had the time to implement it.

The include paths used by the indexer are located inside the .cproject xml
file.

Example:
<option id=" org.eclipse.cdt.build.core.settings.holder.incpaths.38026012 2 "
name="Include Paths"
superClass="org.eclipse.cdt.build.core.settings.holder.incpaths "
valueType="includePath">
<listOptionValue builtIn="false"
value=" &quot;C:\svn_work\branches\intlev5-tck6\include&quot ; "/>
<listOptionValue builtIn="false"
value=" &quot;C:\svn_work\branches\intlev5-tck6\ws\include&q uot; "/>
<listOptionValue builtIn="false"
value=" &quot;C:\svn_work\branches\intlev5-tck6\af\include&q uot; "/>
</option>

Extract the -I .... from the makefile (We have all -I paths stored inside
a variable called INCLUDES) (strip -I and split each path) to a separate
xml file and then use xslt to merge or overwrite the extracted lines into
the .cproject file under the <option id="...incpaths"> node.

/Kristofer

Ron wrote:
> So I understand that there is NO WAY for eclipse to observe the build
> results of an external makefile, and getting the include paths
> automatically.
> That is exactly what I need at the moment, because I work around the rest
> of the problems (except for opening the include file directly), by
> creating a new project with the additional source tree, and making a
> reference to it from my project.

> By the way, if I add a reference to the project - what are the
> implications? What can it affect? Can my build be affected in any way,
> even though I use an external makefile? (it's hard to believe, but I'm
> asking just in case)

> That would be a feature I would expect to be in the CDT as it shouldn't be
> too complicated, probably just some grep -I [fileList] kind of work.
Re: Using Eclipse with an already existing C/C++ project [message #210682 is a reply to message #210485] Wed, 27 February 2008 16:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ronbbnd.gmail.com

Axel Mueller wrote:

> Ron wrote:
>> The problem with import is that it copies the entire directory structure,
>> so I do not work anymore on the project, and would have to copy the files
>> I work on every time, which is error prone.

> It is not necessary to copy your source files into the workspace. If you
> have an existing source tree you should do the following:
> 1) create a new C/C++ project in Eclipse with New->Project->C/C++
> 2) in the appearing project wizard *unselect* "Use default location" and
> choose the location of your existing source tree with the browse button
> 3) select "Makefile project" (Linux gcc toolchain or whatever you are
> using) then click Finish
> You have now a C/C++ project that resides in your source tree (.project
> and .cproject files are stored there).

> The indexer should now partially work. To get better indexer results it is
> necessary to build the project. Eclipse will scan then the output (object
> files) and select the correct include paths by itself (see your problem
> with #include <bracketHeader.h>).

>> Another issue is that the makefile for the entire project does not reside
>> within the imported directory tree. I guess I can work around this using a
>> custom ant build, or maybe another makefile, but this will still not solve
>> the indexing problems.
>> (By the way, I am not proficient with makefiles - how can I make the
>> makefile run from a different working directory?)

> 1) Open the properties dialog of your newly created project (right click
> in the navigator or project explorer view on the project).
> 2) Go to C/C++ build, there you can choose your "Build command" (make -f
> YOUR_MAKEFILE). You can use different Eclipse variables to select a file
> outside of your workspace (click "Variables.." and see yourself). Probably
> you have to define the "Build directory" as well.

> If your compiled object files and linked executable reside outside of your
> source tree (out-of-source build). In this case you will need a linked
> folder to the output directory and set the output location correctly o
> Eclipse can see and scan the output:
> 1) Project properties->C/C++ General->Path and Symbols->Output location
> 2) Click "Create / link folder"
> 3) Click Advanced and select "Link to folder in the file system"
> 4) Browse your file system or select a variable (you can define variables
> for linked folders in the general preferences dialog Windows->Preferences:
> General->Workspace->Linked Resources)

The problem is that the object files and the executable are spread over
too many places - the project is composed of "sub projects" - each of
which has a "build/" subdirectory, in which the object files reside, and
each sub-project may have other sub-objects and so on.

That makes it impossible to track the location of the output files, and
link the eclipse to them.
Re: Using Eclipse with an already existing C/C++ project [message #210737 is a reply to message #210682] Thu, 28 February 2008 07:45 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Ron wrote:
> The problem is that the object files and the executable are spread over
> too many places - the project is composed of "sub projects" - each of
> which has a "build/" subdirectory, in which the object files reside, and
> each sub-project may have other sub-objects and so on.

> That makes it impossible to track the location of the output files, and
> link the eclipse to them.
Do I understand you correctly that your output directories are ordered
like this:
TOP
-> subprj1
-> build
-> subprj2
-> build
-> subprj4
-> build

In this case you can link in Eclipse to the TOP directory.

It would be helpful if you could specify the layout of your src and output
tree.

Axel


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Using Eclipse with an already existing C/C++ project [message #210761 is a reply to message #210737] Thu, 28 February 2008 13:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ronbbnd.gmail.com

Axel Mueller wrote:

> Ron wrote:
>> The problem is that the object files and the executable are spread over
>> too many places - the project is composed of "sub projects" - each of
>> which has a "build/" subdirectory, in which the object files reside, and
>> each sub-project may have other sub-objects and so on.

>> That makes it impossible to track the location of the output files, and
>> link the eclipse to them.
> Do I understand you correctly that your output directories are ordered
> like this:
> TOP
> -> subprj1
> -> build
> -> subprj2
> -> build
> -> subprj4
> -> build

> In this case you can link in Eclipse to the TOP directory.

> It would be helpful if you could specify the layout of your src and output
> tree.

> Axel

You understood well but:
1. Every subprj folder can have other subfolders, in addition to the build.
2. There are two different "TOP" (i.e. root folders):
2.1
one in $INF - This tree countains some infrastructure files, common to
other projects as well. The makefile for the entire project resides within
$INF/build

2.2
and the other in $APP - where our project's specific "sub-projects" reside
in.


So, It goes pretty much like this:

$APP/
-> subprj1
-> build
-> Debug
-> Object files
-> Executable files
-> libraries, etc.
-> Makefile
-> *** and other make files for subprj1, called by Makefile
***

-> include
-> src
-> subprj2
-> build
-> subprj4
-> build
-> subPro1
-> build
-> include
-> src
-> subPro2





same goes for $INF



etcetera, etcetera...
Re: Using Eclipse with an already existing C/C++ project [message #210805 is a reply to message #210761] Thu, 28 February 2008 16:41 Go to previous messageGo to next message
Mike Jackson is currently offline Mike JacksonFriend
Messages: 128
Registered: July 2009
Senior Member
On 2008-02-28 08:07:20 -0500, ronbbnd@gmail.com (Ron) said:

> Axel Mueller wrote:
>
>> Ron wrote:
>>> The problem is that the object files and the executable are spread over
>>> too many places - the project is composed of "sub projects" - each of
>>> which has a "build/" subdirectory, in which the object files reside,
>>> and each sub-project may have other sub-objects and so on.
>
>>> That makes it impossible to track the location of the output files, and
>>> link the eclipse to them.
>> Do I understand you correctly that your output directories are ordered
>> like this:
>> TOP
>> -> subprj1
>> -> build
>> -> subprj2
>> -> build
>> -> subprj4
>> -> build
>
>> In this case you can link in Eclipse to the TOP directory.
>
>> It would be helpful if you could specify the layout of your src and
>> output tree.
>
>> Axel
>
> You understood well but:
> 1. Every subprj folder can have other subfolders, in addition to the build.
> 2. There are two different "TOP" (i.e. root folders):
> 2.1
> one in $INF - This tree countains some infrastructure files, common to
> other projects as well. The makefile for the entire project resides
> within $INF/build
>
> 2.2
> and the other in $APP - where our project's specific "sub-projects" reside in.
>
>
> So, It goes pretty much like this:
>
> $APP/
> -> subprj1
> -> build
> -> Debug
> -> Object files
> -> Executable files
> -> libraries, etc.
> -> Makefile
> -> *** and other make files for subprj1, called by Makefile ***
> -> include
> -> src
> -> subprj2
> -> build
> -> subprj4
> -> build
> -> subPro1
> -> build
> -> include
> -> src
> -> subPro2
>
> same goes for $INF
>
> etcetera, etcetera...

Where is the "top level" makefile. The makefile that you would invoke
to build the entire project?

That is where you want to point "make" at. For instance. I use CMake
and my "makefile" is located in the "Build" directory. I then use the
following custom build command:

make -C ${project_loc}/Build

This works for lots of projects that I use, including larger ones like
VTK, ITK, ParaView and CMake itself.

Mike
Re: Using Eclipse with an already existing C/C++ project [message #210817 is a reply to message #210805] Thu, 28 February 2008 16:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ronbbnd.gmail.com

Mike Jackson wrote:

> On 2008-02-28 08:07:20 -0500, ronbbnd@gmail.com (Ron) said:

>> Axel Mueller wrote:
>>
>>> Ron wrote:
>>>> The problem is that the object files and the executable are spread over
>>>> too many places - the project is composed of "sub projects" - each of
>>>> which has a "build/" subdirectory, in which the object files reside,
>>>> and each sub-project may have other sub-objects and so on.
>>
>>>> That makes it impossible to track the location of the output files, and
>>>> link the eclipse to them.
>>> Do I understand you correctly that your output directories are ordered
>>> like this:
>>> TOP
>>> -> subprj1
>>> -> build
>>> -> subprj2
>>> -> build
>>> -> subprj4
>>> -> build
>>
>>> In this case you can link in Eclipse to the TOP directory.
>>
>>> It would be helpful if you could specify the layout of your src and
>>> output tree.
>>
>>> Axel
>>
>> You understood well but:
>> 1. Every subprj folder can have other subfolders, in addition to the build.
>> 2. There are two different "TOP" (i.e. root folders):
>> 2.1
>> one in $INF - This tree countains some infrastructure files, common to
>> other projects as well. The makefile for the entire project resides
>> within $INF/build
>>
>> 2.2
>> and the other in $APP - where our project's specific "sub-projects" reside
in.
>>
>>
>> So, It goes pretty much like this:
>>
>> $APP/
>> -> subprj1
>> -> build
>> -> Debug
>> -> Object files
>> -> Executable files
>> -> libraries, etc.
>> -> Makefile
>> -> *** and other make files for subprj1, called by Makefile
***
>> -> include
>> -> src
>> -> subprj2
>> -> build
>> -> subprj4
>> -> build
>> -> subPro1
>> -> build
>> -> include
>> -> src
>> -> subPro2
>>
>> same goes for $INF
>>
>> etcetera, etcetera...

> Where is the "top level" makefile. The makefile that you would invoke
> to build the entire project?

> That is where you want to point "make" at. For instance. I use CMake
> and my "makefile" is located in the "Build" directory. I then use the
> following custom build command:

> make -C ${project_loc}/Build

> This works for lots of projects that I use, including larger ones like
> VTK, ITK, ParaView and CMake itself.

> Mike

The top level makefile path is:
$INF/build/Makefile

(Makefile is the file name)


When you use such a make file, does the entire project get indexed?
Including the include files too? (i.e. is all -IsomeIncludePath added
automatically to the indexer?)
Re: Using Eclipse with an already existing C/C++ project [message #210832 is a reply to message #210817] Thu, 28 February 2008 17:33 Go to previous messageGo to next message
Mike Jackson is currently offline Mike JacksonFriend
Messages: 128
Registered: July 2009
Senior Member
On 2008-02-28 11:50:27 -0500, ronbbnd@gmail.com (Ron) said:

> Mike Jackson wrote:
>
>> On 2008-02-28 08:07:20 -0500, ronbbnd@gmail.com (Ron) said:
>
>>> Axel Mueller wrote:
>>>
>>>> Ron wrote:
>>>>> The problem is that the object files and the executable are spread over
>>>>> too many places - the project is composed of "sub projects" - each of
>>>>> which has a "build/" subdirectory, in which the object files reside,
>>>>> and each sub-project may have other sub-objects and so on.
>>>
>>>>> That makes it impossible to track the location of the output files, and
>>>>> link the eclipse to them.
>>>> Do I understand you correctly that your output directories are ordered
>>>> like this:
>>>> TOP
>>>> -> subprj1
>>>> -> build
>>>> -> subprj2
>>>> -> build
>>>> -> subprj4
>>>> -> build
>>>
>>>> In this case you can link in Eclipse to the TOP directory.
>>>
>>>> It would be helpful if you could specify the layout of your src and
>>>> output tree.
>>>
>>>> Axel
>>>
>>> You understood well but:
>>> 1. Every subprj folder can have other subfolders, in addition to the build.
>>> 2. There are two different "TOP" (i.e. root folders):
>>> 2.1
>>> one in $INF - This tree countains some infrastructure files, common to
>>> other projects as well. The makefile for the entire project resides
>>> within $INF/build
>>>
>>> 2.2
>>> and the other in $APP - where our project's specific "sub-projects" reside
> in.
>>>
>>>
>>> So, It goes pretty much like this:
>>>
>>> $APP/
>>> -> subprj1
>>> -> build
>>> -> Debug
>>> -> Object files
>>> -> Executable files
>>> -> libraries, etc.
>>> -> Makefile
>>> -> *** and other make files for subprj1, called by Makefile
> ***
>>> -> include
>>> -> src
>>> -> subprj2
>>> -> build
>>> -> subprj4
>>> -> build
>>> -> subPro1
>>> -> build
>>> -> include
>>> -> src
>>> -> subPro2
>>>
>>> same goes for $INF
>>>
>>> etcetera, etcetera...
>
>> Where is the "top level" makefile. The makefile that you would invoke
>> to build the entire project?
>
>> That is where you want to point "make" at. For instance. I use CMake
>> and my "makefile" is located in the "Build" directory. I then use the
>> following custom build command:
>
>> make -C ${project_loc}/Build
>
>> This works for lots of projects that I use, including larger ones like
>> VTK, ITK, ParaView and CMake itself.
>
>> Mike
>
> The top level makefile path is:
> $INF/build/Makefile
>
> (Makefile is the file name)
>
>
> When you use such a make file, does the entire project get indexed?
> Including the include files too? (i.e. is all -IsomeIncludePath added
> automatically to the indexer?)

So your custom build command would be something like:

make -C ${project_loc}/$INF/build

You need to substitute the real directory for $INF.
${project_loc} is an eclipse variable.


your project _should_ get indexed. Doesn't mean it _will_ get indexed
properly. The defaults are set so that CDT should be scanning the
output from the build command to discover the include paths.

Mike
Re: Using Eclipse with an already existing C/C++ project [message #210893 is a reply to message #210480] Fri, 29 February 2008 14:20 Go to previous messageGo to next message
Chris Recoskie is currently offline Chris RecoskieFriend
Messages: 163
Registered: July 2009
Senior Member
Ron wrote:
> So I understand that there is NO WAY for eclipse to observe the build
> results of an external makefile, and getting the include paths
> automatically.

This is not true. You can set the CDT build command to be any arbitrary
command you want, and the output will be parsed by the "scanner info
provider" to look for compiler invocations. The invocations are parsed
for the -I and -D flags.

So, as long as the scanner info parser knows how to parse the output of
your compiler, you should be able to get it to work.

--
Chris Recoskie
Team Lead, IBM CDT Team
IBM Toronto
http://www.eclipse.org/cdt
Re: Using Eclipse with an already existing C/C++ project [message #210985 is a reply to message #210893] Sat, 01 March 2008 14:24 Go to previous message
Eclipse UserFriend
Originally posted by: kristofer.hansson.maps.gmail.com

Hi Chris

This sounds interesting! Guess this this doesn't seem to work that well
thou, since using simple make as default build command along with standard
calls to g++ with -I flags doesn't seem to help + the fact that the
questions came up.

Could you help pointing me to the standard CDT "scanner info provider"
source to look at? Would be interesting to try creating a custom parser
that actually adds paths to the list found under Project properties->C/C++
General->Includepaths... list, or is there another way of actually check
what -I directories that have been found by the "scanner info provider"?

/Kristofer

Chris Recoskie wrote:

> Ron wrote:
>> So I understand that there is NO WAY for eclipse to observe the build
>> results of an external makefile, and getting the include paths
>> automatically.

> This is not true. You can set the CDT build command to be any arbitrary
> command you want, and the output will be parsed by the "scanner info
> provider" to look for compiler invocations. The invocations are parsed
> for the -I and -D flags.

> So, as long as the scanner info parser knows how to parse the output of
> your compiler, you should be able to get it to work.
Previous Topic:Qt with eclipse
Next Topic:JRE problems?
Goto Forum:
  


Current Time: Thu Jul 25 16:24:11 GMT 2024

Powered by FUDForum. Page generated in 0.04422 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top