Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » makefile
makefile [message #56354] Fri, 03 January 2003 01:24 Go to next message
Eclipse UserFriend
Originally posted by: katia.vivax-tech.com

Hi to All,
I have an error in my makefile which is like this:
objects = hello.o tpl2doc.o

hello : $(objects)
gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++

$(objects) : hello.cpp tpldoc.cpp
gcc -c hello.cpp
gcc -c tpl2doc.cpp

all :
${MAKE} hello

PHONY : clean
clean :
-del hello.exe $(objects)
-del tpl2doc.exe $(objects)

I did not find documentation how to write a good makefile for eclipse for
more than one cpp file. Can somebody point out my error, or provide a URL
with info?

Any Help will be gratly appreciated !
Re: makefile [message #56422 is a reply to message #56354] Fri, 03 January 2003 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bud_s2460.hotmail.com

Hi Kate,

I'm no expert on make but maybe i can give you a shove in the right
direction ;)

You dont mention wether you are using linux or windows.

Some general issues I can see are that:

> hello : $(objects)
> gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
> gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++

should be:

hello : $(objects)
gcc -o hello hello.o -L /usr/bin/gcc -lstdc++
gcc -o tpl2doc tpl2doc.o -L /usr/bin/gcc -lstdc++

and:

> $(objects) : hello.cpp tpldoc.cpp
> gcc -c hello.cpp
> gcc -c tpl2doc.cpp

should be:

hello.o : hello.cpp
gcc -c hello.cpp

tpl2doc.o : tpldoc.cpp
gcc -c tpl2doc.cpp

and

> PHONY : clean
> clean :
> -del hello.exe $(objects)
> -del tpl2doc.exe $(objects)

should be:

..PHONY : clean

clean :
-del hello.exe tpl2doc.exe $(objects)

==== linux specific ===========

If you are using linux:
double check the path to gcc is correct in the -L switch ("find -type
f -name *gcc* -print" should help you locate the right location)
change -del to -rm in the clean section
remove the .exe extension from hello.exe and tpl2doc.exe in the clean
section.

======end linux specific======

==== win specific ===========

If you are using windows I found that I had to do a bit of fiddling to get
it all working.
The following works well for me in win2k - there may be a better way tho ;)

First add the path to the bin directory of MinGW to your system PATH (right
click on My Computer>properties>advanced>enviromentvariables).

Modify the:

gcc -o hello hello.o -L /usr/bin/gcc -lstdc++
gcc -o tpl2doc tpl2doc.o -L /usr/bin/gcc -lstdc++

to:
gcc -o hello hello.o -lstdc++
gcc -o tpl2doc tpl2doc.o -lstdc++

Then make a batch file in your project directory called make.bat with the
contents.:

mingw32-make -f makefile %1 %2

In eclipse in the C++ projects view right click your
project>properties>c/c++ project then uncheck the use default build command
and type make.bat in the box.

==== end win specific ===========

Go through the whole make file and make sure that you have used a single tab
to indent the required lines as make is exteremly fussy about this. When you
have done it save the project.

Now try to rebuild the project, if it doesnt work or if it does but you want
to know why you may want to have a look at
http://www.gnu.org/manual/make/html_mono/make.html#SEC_Conte nts

hf

BuD

"Kate" <katia@vivax-tech.com> wrote in message
news:av2op2$4r5$1@rogue.oti.com...
> Hi to All,
> I have an error in my makefile which is like this:
> objects = hello.o tpl2doc.o
>
> hello : $(objects)
> gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
> gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++
>
> $(objects) : hello.cpp tpldoc.cpp
> gcc -c hello.cpp
> gcc -c tpl2doc.cpp
>
> all :
> ${MAKE} hello
>
> PHONY : clean
> clean :
> -del hello.exe $(objects)
> -del tpl2doc.exe $(objects)
>
> I did not find documentation how to write a good makefile for eclipse for
> more than one cpp file. Can somebody point out my error, or provide a URL
> with info?
>
> Any Help will be gratly appreciated !
>
>
>
Re: makefile [message #56449 is a reply to message #56422] Fri, 03 January 2003 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bud_s2460.hotmail.com

oops - correction:

> PHONY : clean
> clean :
> -del hello.exe $(objects)
> -del tpl2doc.exe $(objects)

should be:

..PHONY : clean

clean :
-del hello.exe $(objects)

;) BuD



"BuD" <bud_s2460@hotmail.com> wrote in message
news:av3vd2$lrk$1@rogue.oti.com...
> Hi Kate,
>
> I'm no expert on make but maybe i can give you a shove in the right
> direction ;)
>
> You dont mention wether you are using linux or windows.
>
> Some general issues I can see are that:
>
> > hello : $(objects)
> > gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
> > gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++
>
> should be:
>
> hello : $(objects)
> gcc -o hello hello.o -L /usr/bin/gcc -lstdc++
> gcc -o tpl2doc tpl2doc.o -L /usr/bin/gcc -lstdc++
>
> and:
>
> > $(objects) : hello.cpp tpldoc.cpp
> > gcc -c hello.cpp
> > gcc -c tpl2doc.cpp
>
> should be:
>
> hello.o : hello.cpp
> gcc -c hello.cpp
>
> tpl2doc.o : tpldoc.cpp
> gcc -c tpl2doc.cpp
>
> and
>
> > PHONY : clean
> > clean :
> > -del hello.exe $(objects)
> > -del tpl2doc.exe $(objects)
>
> should be:
>
> .PHONY : clean
>
> clean :
> -del hello.exe tpl2doc.exe $(objects)
>
> ==== linux specific ===========
>
> If you are using linux:
> double check the path to gcc is correct in the -L switch ("find -type
> f -name *gcc* -print" should help you locate the right location)
> change -del to -rm in the clean section
> remove the .exe extension from hello.exe and tpl2doc.exe in the clean
> section.
>
> ======end linux specific======
>
> ==== win specific ===========
>
> If you are using windows I found that I had to do a bit of fiddling to get
> it all working.
> The following works well for me in win2k - there may be a better way tho
;)
>
> First add the path to the bin directory of MinGW to your system PATH
(right
> click on My Computer>properties>advanced>enviromentvariables).
>
> Modify the:
>
> gcc -o hello hello.o -L /usr/bin/gcc -lstdc++
> gcc -o tpl2doc tpl2doc.o -L /usr/bin/gcc -lstdc++
>
> to:
> gcc -o hello hello.o -lstdc++
> gcc -o tpl2doc tpl2doc.o -lstdc++
>
> Then make a batch file in your project directory called make.bat with the
> contents.:
>
> mingw32-make -f makefile %1 %2
>
> In eclipse in the C++ projects view right click your
> project>properties>c/c++ project then uncheck the use default build
command
> and type make.bat in the box.
>
> ==== end win specific ===========
>
> Go through the whole make file and make sure that you have used a single
tab
> to indent the required lines as make is exteremly fussy about this. When
you
> have done it save the project.
>
> Now try to rebuild the project, if it doesnt work or if it does but you
want
> to know why you may want to have a look at
> http://www.gnu.org/manual/make/html_mono/make.html#SEC_Conte nts
>
> hf
>
> BuD
>
> "Kate" <katia@vivax-tech.com> wrote in message
> news:av2op2$4r5$1@rogue.oti.com...
> > Hi to All,
> > I have an error in my makefile which is like this:
> > objects = hello.o tpl2doc.o
> >
> > hello : $(objects)
> > gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
> > gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++
> >
> > $(objects) : hello.cpp tpldoc.cpp
> > gcc -c hello.cpp
> > gcc -c tpl2doc.cpp
> >
> > all :
> > ${MAKE} hello
> >
> > PHONY : clean
> > clean :
> > -del hello.exe $(objects)
> > -del tpl2doc.exe $(objects)
> >
> > I did not find documentation how to write a good makefile for eclipse
for
> > more than one cpp file. Can somebody point out my error, or provide a
URL
> > with info?
> >
> > Any Help will be gratly appreciated !
> >
> >
> >
>
>
Re: makefile [message #56587 is a reply to message #56449] Fri, 03 January 2003 21:08 Go to previous message
Eclipse UserFriend
Originally posted by: katia.vivax-tech.com

Thanks for the answer !

This is my first encounter with non-automaticly generated makefile, so it
was very helpfull. I am using linux, but got the makefile from windows FAQ
for CDT
(none available for linux) so that why is: del hello.exe :) my mistake.


BuD wrote:

clean
> > clean :
> > -del hello.exe $(objects)
> > -del tpl2doc.exe $(objects)

> should be:

> ..PHONY : clean

> clean :
> -del hello.exe $(objects)

> ;) BuD



> "BuD" <bud_s2460@hotmail.com> wrote in message
> news:av3vd2$lrk$1@rogue.oti.com...
> > Hi Kate,
> >
> > I'm no expert on make but maybe i can give you a shove in the right
> > direction ;)
> >
> > You dont mention wether you are using linux or windows.
> >
> > Some general issues I can see are that:
> >
> > > hello : $(objects)
> > > gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
> > > gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++
> >
> > should be:
> >
> > hello : $(objects)
> > gcc -o hello hello.o -L /usr/bin/gcc -lstdc++
> > gcc -o tpl2doc tpl2doc.o -L /usr/bin/gcc -lstdc++
> >
> > and:
> >
> > > $(objects) : hello.cpp tpldoc.cpp
> > > gcc -c hello.cpp
> > > gcc -c tpl2doc.cpp
> >
> > should be:
> >
> > hello.o : hello.cpp
> > gcc -c hello.cpp
> >
> > tpl2doc.o : tpldoc.cpp
> > gcc -c tpl2doc.cpp
> >
> > and
> >
> > > PHONY : clean
> > > clean :
> > > -del hello.exe $(objects)
> > > -del tpl2doc.exe $(objects)
> >
> > should be:
> >
> > .PHONY : clean
> >
> > clean :
> > -del hello.exe tpl2doc.exe $(objects)
> >
> > ==== linux specific ===========
> >
> > If you are using linux:
> > double check the path to gcc is correct in the -L switch ("find -type
> > f -name *gcc* -print" should help you locate the right location)
> > change -del to -rm in the clean section
> > remove the .exe extension from hello.exe and tpl2doc.exe in the clean
> > section.
> >
> > ======end linux specific======
> >
> > ==== win specific ===========
> >
> > If you are using windows I found that I had to do a bit of fiddling to get
> > it all working.
> > The following works well for me in win2k - there may be a better way tho
> ;)
> >
> > First add the path to the bin directory of MinGW to your system PATH
> (right
> > click on My Computer>properties>advanced>enviromentvariables).
> >
> > Modify the:
> >
> > gcc -o hello hello.o -L /usr/bin/gcc -lstdc++
> > gcc -o tpl2doc tpl2doc.o -L /usr/bin/gcc -lstdc++
> >
> > to:
> > gcc -o hello hello.o -lstdc++
> > gcc -o tpl2doc tpl2doc.o -lstdc++
> >
> > Then make a batch file in your project directory called make.bat with the
> > contents.:
> >
> > mingw32-make -f makefile %1 %2
> >
> > In eclipse in the C++ projects view right click your
> > project>properties>c/c++ project then uncheck the use default build
> command
> > and type make.bat in the box.
> >
> > ==== end win specific ===========
> >
> > Go through the whole make file and make sure that you have used a single
> tab
> > to indent the required lines as make is exteremly fussy about this. When
> you
> > have done it save the project.
> >
> > Now try to rebuild the project, if it doesnt work or if it does but you
> want
> > to know why you may want to have a look at
> > http://www.gnu.org/manual/make/html_mono/make.html#SEC_Conte nts
> >
> > hf
> >
> > BuD
> >
> > "Kate" <katia@vivax-tech.com> wrote in message
> > news:av2op2$4r5$1@rogue.oti.com...
> > > Hi to All,
> > > I have an error in my makefile which is like this:
> > > objects = hello.o tpl2doc.o
> > >
> > > hello : $(objects)
> > > gcc -o hello $(objects) -L /usr/bin/gcc -lstdc++
> > > gcc -o tpl2doc $(objects) -L /usr/bin/gcc -lstdc++
> > >
> > > $(objects) : hello.cpp tpldoc.cpp
> > > gcc -c hello.cpp
> > > gcc -c tpl2doc.cpp
> > >
> > > all :
> > > ${MAKE} hello
> > >
> > > PHONY : clean
> > > clean :
> > > -del hello.exe $(objects)
> > > -del tpl2doc.exe $(objects)
> > >
> > > I did not find documentation how to write a good makefile for eclipse
> for
> > > more than one cpp file. Can somebody point out my error, or provide a
> URL
> > > with info?
> > >
> > > Any Help will be gratly appreciated !
> > >
> > >
> > >
> >
> >
Previous Topic:problem with step over debugging
Next Topic:scrollbars of the Editor and Outline window do not work
Goto Forum:
  


Current Time: Sat Oct 19 10:34:10 GMT 2024

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

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

Back to the top