Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > makefile in textbook example not work(at stage of make install), plz help

Reply
Thread Tools

makefile in textbook example not work(at stage of make install), plz help

 
 
eric
Guest
Posts: n/a
 
      07-02-2011
Dear advanced c++ programers:

I tried to copy and test a piece simple makefile code with
simple .cpp, .hpp code(s) which purpose is teach reader
how to use gnu make (especially on unix/linux) build (complex
application). That is the book (C++ Cookbook) chapter 1
example 1-2
1-3
1-20
1-22
1-23
1-24
-------------------------------------------------but it failed at
stage of make install (make TARGET=install)--------------
-------the following is after
make-------------------------------------------------------------------------------------------------------

eric@eric-laptop:~/cppcookbook/ch1$ ls
binaries georgeringo hellobeatles johnpaul Makefile
eric@eric-laptop:~/cppcookbook/ch1$ make TARGET=install
make --directory=johnpaul install
make[1]: Entering directory `/home/eric/cppcookbook/ch1/johnpaul'
mkdir -p ../binaries
cp -p libjohnpaul.a ../binaries
make[1]: Leaving directory `/home/eric/cppcookbook/ch1/johnpaul'
make --directory=georgeringo install
make[1]: Entering directory `/home/eric/cppcookbook/ch1/georgeringo'
mkdir -p ../binaries
cp -p libgeorgeringo.so ../binaries
make[1]: Leaving directory `/home/eric/cppcookbook/ch1/georgeringo'
make --directory=hellobeatles install
make[1]: Entering directory `/home/eric/cppcookbook/ch1/hellobeatles'
mkdir -p ../binaries
cp -p hellobeatles ../binaries
cp: cannot stat `hellobeatles': No such file or directory
make[1]: *** [install] Error 1
make[1]: Leaving directory `/home/eric/cppcookbook/ch1/hellobeatles'
make: *** [hellobeatles] Error 2
eric@eric-laptop:~/cppcookbook/ch1$
---------------------------------------------------------------------------------------------------------
--------This is Makefile in /
hellobeatles------------------------------------------------
--------------------------------------------------------------------------------------
# Specify the source files, target files, the build directories
# and the install idrectory
SOURCES = hellobeatles.cpp
OUTPUTFILE = hellobeatles
LIBJOHNPAUL = libjohnpaul.a
LIBGEORGERINGO = libgeorgeringo.so
JOHNPAULDIR = ../johnpaul
GEORGERINGODIR = ../georgeringo
INSTALLDIR = ../binaries

#
# Add the parent directory as an include path
#
CPPFLAGS += -I..

#
# Default target
#

..PHONY: all
all: $(HELLOBEATLES)

#
# Target to build the executable.
#
$(OUTPUTFILE): $(subst .cpp,.o,$(SOURCES)) \
$(JOHNPAULDIR)/$(LIBJOHNPAUL) \
$(GEORGERINGODIR)/$(LIBGEORGERINGO)
$(CXX) $(LDFLAGS) -o $@ $^

..PHONY: install
install:
mkdir -p $(INSTALLDIR)
cp -p $(OUTPUTFILE) $(INSTALLDIR)

..PHONY: clean
clean:
rm -f *.o
rm -f $(OUTPUTFILE)

# Generate dependencies of .cpp files on .hpp files
include $(subst .cpp,.d,$(SOURCES))

%.d: %.cpp
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
---------------------------------------------------------------------------------------
this is hellobeatles.cpp---------------------------------------
-----------------------------------------------
#include "johnpaul/johnpaul.hpp"
#include "georgeringo/georgeringo.hpp"

int main()
{
// Prints "John, Paul, George, and Ringo\n"
johnpaul();
georgeringo();
}
------------------------------------------------------------------------------
since my /hellobeatles directory after make, only produce
hellobeatles.d, but make TARGET=install demand
hellobeatles
which my directory don't have

the other examples codes mentioned in above(cpp,hpp,makefile) can be
found/download from
http://examples.oreilly.com/9780596007614/

or you have that book by yourself now.

I think mainly is Makefile in /hellobeatles cause error, but I have
no way(out of wit and experience) to fix it.
plz help
Eric
 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      07-02-2011
On Sat, 2011-07-02, eric wrote:
> Dear advanced c++ programers:
>
> I tried to copy and test a piece simple makefile code with
> simple .cpp, .hpp code(s) which purpose is teach reader
> how to use gnu make (especially on unix/linux) build (complex
> application).


That's not a C++ question, so I'm afraid it's offtopic here.

....
> since my /hellobeatles directory after make, only produce
> hellobeatles.d, but make TARGET=install demand
> hellobeatles
> which my directory don't have
>
> the other examples codes mentioned in above(cpp,hpp,makefile) can be
> found/download from
> http://examples.oreilly.com/9780596007614/


(I actually did that, but the file didn't unzip to any directory
structure, just hundreds of files with very short and cryptic names.
All of the Makefiles ("1-14.mak" and so on) refer to files which don't
exist, and so do the source files themselves. I can only conclude that
the example code is broken.)

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
 
eric
Guest
Posts: n/a
 
      07-02-2011
On Jul 2, 8:55*am, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:
> On Sat, 2011-07-02, eric wrote:
> > Dear advanced c++ programers:

>
> > * I tried to copy and test a piece simple makefile code with
> > simple .cpp, .hpp code(s) which purpose is teach reader
> > how to use gnu make (especially on unix/linux) build (complex
> > application).

>
> That's not a C++ question, so I'm afraid it's offtopic here.
>
> ...
>
> > since my /hellobeatles directory after make, only produce
> > hellobeatles.d, but make TARGET=install demand
> > hellobeatles
> > which my directory don't have

>
> > the other examples codes mentioned in above(cpp,hpp,makefile) can be
> > found/download from
> >http://examples.oreilly.com/9780596007614/

>
> (I actually did that, but the file didn't unzip to any directory
> structure, just hundreds of files with very short and cryptic names.
> All of the Makefiles ("1-14.mak" and so on)


You don't need 1-14.mak

In last email, I missing, it should include
1-1 (it include both .hpp and .cpp)
1-2

refer to files which don't
> exist, and so do the source files themselves. I can only conclude that
> the example code is broken.)


Since my question is only concern to very beginning, there is nothing
about broken we need to worry about

>
> /Jorgen
>
> --
> * // Jorgen Grahn <grahn@ *Oo *o. * . *.
> \X/ * * snipabacken.se> * O *o * .


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PLZ HELP ME ...CHANGING OF MAKEFILE FROM FREEBSD TO REDHAT 9.0 ...... yogesh Computer Support 0 12-27-2006 06:17 AM
TEXTBOOK EXAMPLE OF SEARCH ENGINE INDEXING Borked Pseudo Mailed HTML 1 09-10-2006 01:48 AM
Initialization -- One Stage or Two Stage Brian Folke Seaberg C++ 4 01-04-2005 09:12 PM
Re: plz help!!! plz plz plz plzplzplz help the noob alkzy Microsoft Certification 0 10-31-2004 10:04 PM
Computer Problems... Plz Plz Plz HELP ME..... Nick Computer Support 0 06-04-2004 08:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57