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

E

eric

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
 
J

Jorgen Grahn

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
 
E

eric

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

...



(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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top