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

Discussion in 'C++' started by eric, Jul 2, 2011.

  1. eric

    eric Guest

    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
     
    eric, Jul 2, 2011
    #1
    1. Advertising

  2. eric

    Jorgen Grahn Guest

    Re: makefile in textbook example not work(at stage of makeinstall), plz help

    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 .
     
    Jorgen Grahn, Jul 2, 2011
    #2
    1. Advertising

  3. eric

    eric Guest

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

    On Jul 2, 8:55 am, Jorgen Grahn <> 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   .
     
    eric, Jul 2, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Folke Seaberg

    Initialization -- One Stage or Two Stage

    Brian Folke Seaberg, Jan 4, 2005, in forum: C++
    Replies:
    4
    Views:
    738
    Howard
    Jan 4, 2005
  2. Replies:
    1
    Views:
    408
  3. Replies:
    2
    Views:
    359
    Nick Keighley
    Nov 24, 2006
  4. Replies:
    1
    Views:
    371
  5. Ramon F Herrera
    Replies:
    4
    Views:
    281
    Victor Bazarov
    Nov 28, 2007
Loading...

Share This Page