'make' error - I must not understand make correctly

'make' error - I must not understand make correctly

Post by Ed Doyl » Sat, 03 May 2003 11:07:41



Hi,
I must have a misunderstanding of how make works.  Here is a simple program
to illustrate my problem.

I have a file called a.cpp and a makefile that looks like this:

CC = g++

all :
    ar -r mylib a.o

If I type make all, I would expect make to not find any file called a.o, but
notice that there is a file called a.cpp and would then use the built in
suffix rules to build a.o from a.cpp.  However, make returns an error for
not being able to find a.o.

If I first issue the command g++ -c a.cpp which builds a.o and then do make
all, mylib is built with no problem.

I must have some misunderstanding of this.  Why does a.o not get built by
the implicit rules of make?

Any help in clearing up my misunderstanding, even flaming would be very much
appreciated.

Thanks

Ed Doyle

 
 
 

'make' error - I must not understand make correctly

Post by Tony Curti » Sat, 03 May 2003 11:17:31


>> On Thu, 1 May 2003 22:07:41 -0400,

> Hi, I must have a misunderstanding of how make works.
> Here is a simple program to illustrate my problem.
> I have a file called a.cpp and a makefile that looks
> like this:
> CC = g++

Usually, CC denotes the C compiler; CXX is used for the
C++ compiler.

Quote:> all:
>         ar -r mylib a.o

all: a.o
        ar -r mylib a.o

You need to day that the archive depends on the object.

(BTW static archives traditionally are called thing.a)

I'd probably have done:

    CXX = g++
    CXXFLAGS = ...

    OBJECTS = a.o [ b.o c.o ... ]

    archive.a: $(OBJECTS)
            ar qv[other flags] archive.a $(OBJECTS)

hth
t

 
 
 

'make' error - I must not understand make correctly

Post by Johan Kullsta » Sun, 04 May 2003 05:31:49



> >> On Thu, 1 May 2003 22:07:41 -0400,

> > Hi, I must have a misunderstanding of how make works.
> > Here is a simple program to illustrate my problem.

> > I have a file called a.cpp and a makefile that looks
> > like this:

> > CC = g++

> Usually, CC denotes the C compiler; CXX is used for the
> C++ compiler.

> > all:
> >         ar -r mylib a.o

> all: a.o
>         ar -r mylib a.o

> You need to day that the archive depends on the object.

> (BTW static archives traditionally are called thing.a)

> I'd probably have done:

>     CXX = g++
>     CXXFLAGS = ...

>     OBJECTS = a.o [ b.o c.o ... ]

>     archive.a: $(OBJECTS)
>             ar qv[other flags] archive.a $(OBJECTS)

> hth
> t

make is good at looking inside archives

OBJECTS = lilibrary.a(a.o) lilibrary.a(b.o) lilibrary.a(c.o)

lilibrary.a:    $(OBJECTS)
                ranlib lilibrary.a

--

 
 
 

'make' error - I must not understand make correctly

Post by Andrew B Rye I » Thu, 08 May 2003 09:20:23


I remember having problems with make when I was using spaces
instead of the tab field for indentions. Be careful!


> Hi,
> I must have a misunderstanding of how make works.  Here is a simple program
> to illustrate my problem.

> I have a file called a.cpp and a makefile that looks like this:

> CC = g++

> all :
>     ar -r mylib a.o

> If I type make all, I would expect make to not find any file called a.o, but
> notice that there is a file called a.cpp and would then use the built in
> suffix rules to build a.o from a.cpp.  However, make returns an error for
> not being able to find a.o.

> If I first issue the command g++ -c a.cpp which builds a.o and then do make
> all, mylib is built with no problem.

> I must have some misunderstanding of this.  Why does a.o not get built by
> the implicit rules of make?

> Any help in clearing up my misunderstanding, even flaming would be very much
> appreciated.

> Thanks

> Ed Doyle

--
----------------------------
Skip Rye
----------------------------

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----