This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]