dear fltk or x window by g++ programers:

  So I follow your advice to do
make
---------------------------------
r...@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# ls
build.bat             chapter.12.7.8-1.cpp  Makefile.1
ch12try1.cpp          chapter.12.7.8-2.cpp  Matrix.h
chapter.12.3.cpp      chapter.12.7.9-1.cpp  MatrixIO.h
chapter.12.7.10.cpp   chapter.12.7.9-2.cpp  Point.h
chapter.12.7.1.cpp    Graph.cpp             Simple_window.cpp
chapter.12.7.2.cpp    Graph.h               Simple_window.h
chapter.12.7.3-1.cpp  GUI.cpp               snow_cpp.gif
chapter.12.7.3-2.cpp  GUI.h                 std_lib_facilities.h
chapter.12.7.4.cpp    image.jpg             std_lib_facilities.h.1
chapter.12.7.5.cpp    index.html            t0chapter.12.3.cpp
chapter.12.7.6-1.cpp  index.html.1          t1chapter.12.3.cpp
chapter.12.7.6-2.cpp  index.html.2          t1chapter.12.7.2.cpp
chapter.12.7.6.cpp    index.html.3          Window.cpp
chapter.12.7.7.cpp    Makefile              Window.h
r...@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# make
make[1]: Entering directory `/home/eric/BStrou/usingC++4/code/GUI'
g++ -I"" -Wall -time -O3 -DNDEBUG -o Graph.o -c Graph.cpp
In file included from /usr/include/c++/4.4/ext/hash_map:60,
                 from ../std_lib_facilities.h:32,
                 from Graph.h:13,
                 from Graph.cpp:9:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This 
file includes at least one deprecated or antiquated header which may be removed 
without further notice at a future date. Please use a non-deprecated interface 
with equivalent functionality instead. For a listing of replacement headers and 
interfaces, consult the file backward_warning.h. To disable this warning use 
-Wno-deprecated.
Graph.cpp: In function ‘Graph_lib::Suffix::Encoding 
Graph_lib::get_encoding(const String&)’:
Graph.cpp:394: error: ‘strlen’ was not declared in this scope
# cc1plus 0.53 0.04
make[1]: *** [Graph.o] Error 1
make[1]: Leaving directory `/home/eric/BStrou/usingC++4/code/GUI'
make: *** [../GUI/libbookgui.a] Error 2
r...@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12#
-------------------------------------------------------
and the Makefile is
-------------
e...@eric-laptop:~/BStrou/usingC++4/code/Chapter12$ cat Makefile
#
# This is a common Makefile for code examples from the book
# "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
#

#
# Usage:
#     make        - Build all examples
#     make clean  - Clean all examples
#     make test   - Run the test suite
#

INCLUDES = -I"../GUI" -I"$(FLTK)"
LIBS     = -lstdc++ -lbookgui -lfltk -lfltk_images
CXXFLAGS = $(INCLUDES) -Wall -time -O3 -DNDEBUG
LIBFLAGS = -L"../GUI"
AR       = ar

# NOTE: If under Cygwin you get an error that uname command is not found,
#       make sure there are no folders with space in their names that preceed
#       the path to the Cygwin's bin folder inside your PATH variable.
ifeq ($(shell uname -o),Cygwin)
  OS=Cygwin
else
  OS=$(shell uname)
endif

ifeq ($(OS),Cygwin)
  LIBS := $(LIBS) -lfltk_jpeg -luser32 -lgdi32 -lshell32 -lole32 -luuid 
-lWs2_32 -lComCtl32
else
ifeq ($(OS),Darwin)
  LIBS := $(LIBS) -ljpeg -framework Carbon
else
  LIBS := $(LIBS) -lX11 -ljpeg
endif
endif

.SUFFIXES: .cpp .o

# Create a list of source files.
SOURCES  = $(shell ls *.cpp)
# Create a list of object files from the source file lists.
OBJECTS = ${SOURCES:.cpp=.o}
# Create a list of targets.
TARGETS = ${SOURCES:.cpp=.exe}

# Build all targets by default
all:    $(TARGETS)

# Files with extension .no-link.cpp are not intended for linking
%.no-link.exe: %.no-link.o
        @echo Linking skipped for $@
        @echo 
================================================================================
        @echo Done building $@
        @echo 
================================================================================
        @echo
        @echo

# A rule to build .exe file out of a .o file
%.exe: %.o ../GUI/libbookgui.a
        $(CXX) -o $@ $(LIBFLAGS) $< $(LIBS)
        @echo 
================================================================================
        @echo Done building $@
        @echo 
================================================================================
        @echo
        @echo

# A rule to build .o file out of a .cpp file
%.o: %.cpp
        $(CXX) $(CXXFLAGS) -o $@ -c $<

# A rule to build the common GUI library
./GUI/libbookgui.a: ../GUI/*.h ../GUI/*.cpp
        @(cd ../GUI; $(MAKE))

# A rule to clean all the intermediates and targets
clean:
        rm -rf $(TARGETS) $(OBJECTS) *.out *.stackdump

# A rule to run set of tests
test:
        @for file in *.exe; do \
            name=`basename $$file .exe` ; \
            name=`basename $$name .crash` ; \
            if (ls $$name.crash.exe >/dev/null 2>&1) ; then \
                continue ; \
            fi ; \
            echo ======================================== [ $$file ] ; \
            if (ls $$name.*in >/dev/null 2>&1) ; then \
                for f in $$name.*in; do \
                    echo ; \
                    echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { "$$f" } ; \
                    cat "$$f" ; \
                    echo ; \
                    echo ---------------------------------------- ; \
                    ./$$file < "$$f" ; \
                done ; \
            else \
              ./$$file ; \
            fi \
        done ; \
        echo -n
e...@eric-laptop:~/BStrou/usingC++4/code/Chapter12$
--------------------------------------------------------
As you can see my make is not succesful, strlen was not declared in the scope!

plz help again, thx a lot in advance, eric
////////////////////////////////////////////////////////


------------------------------------------------------------------
> eric wrote:
> > I get a lot compile errors, which is really out of novice as me to figure 
> > out.
> > chapter.12.3.cpp:(.text+0x7d): undefined reference to 
> > `Simple_window::Simple_window(Point, int, int, String const&)'
> > chapter.12.3.cpp:(.text+0x1e7): undefined reference to 
> > `Simple_window::wait_for_button()'
>
>       The above errors seem to be complaining about code in Simple_window.h,
>       code that hasn't been posted here (you just posted the .cpp file, not
>       the .h file on which it depends, and the above errors are about)
>
> > chapter.12.3.cpp:(.text+0x100): undefined reference to 
> > `Graph_lib::Polygon::add(Point)'
> > chapter.12.3.cpp:(.text+0x144): undefined reference to 
> > `Graph_lib::Polygon::add(Point)'
> > chapter.12.3.cpp:(.text+0x188): undefined reference to 
> > `Graph_lib::Polygon::add(Point)'
>
>       These appear to be errors about another library, "Graph_lib",
>       which I take it is something the example needs, and the book provides,
>       and is something you have to compile separately, and link in with
>       your application.
>
>       This is a more complex situation; you're trying to compile a program
>       that depends on more than just FLTK, but several other files as well.
>
>       So a simple: "fltk2-config --compile <yourcode.cpp>" is not enough;
>       other files need to be compiled first (Graph_lib, whatever that is, etc)
>
>       I noticed in the directory listing you provided of your examples,
>       there's a "Makefile" in there, eg:
>
> ----
> r...@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# ls
> build.bat            chapter.12.7.2.cpp    chapter.12.7.6-1.cpp  
> chapter.12.7.8-2.cpp  GUI.cpp       index.html.2  MatrixIO.h         
> std_lib_facilities.h
> ch12try1.cpp         chapter.12.7.3-1.cpp  chapter.12.7.6-2.cpp  
> chapter.12.7.9-1.cpp  GUI.h         index.html.3  Point.h            
> std_lib_facilities.h.1
> chapter.12.3.cpp     chapter.12.7.3-2.cpp  chapter.12.7.6.cpp    
> chapter.12.7.9-2.cpp  image.jpg     Makefile      Simple_window.cpp  
> Window.cpp
>                                                                               
>                        ^^^^^^^^
> ----
>
>       Can you paste the contents of that Makefile here?
>       It will probably give us a good idea of what's involved here.
>
>       It's possible that just running 'make' is what you need.
>       However, it depends on the contents of the Makefile, which
>       may need some small changes to point to where you have fltk2
>       installed before 'make' will work correctly.
>
>       You could try just running 'make'.
>
>
>       Are you sure the book doesn't recommend how to build all the
>       examples? I can't imagine they'd recommend using g++ to build
>       these GUI examples.. only very simple non-GUI apps would build
>       with just 'g++'.
>
>       Is the book's example code and documentation online somewhere?
>
>       At very least, paste us the Makefile that is in your project
>       directory, as that file will likely have all the info in it
>       on how to build all the examples in that directory. (To use
>       a Makefile, you would run 'make')
>
> > r...@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# g++ 
> > -Wno-deprecated chapter.12.3.cpp Simple_window.cpp Graph.cpp GUI.cpp 
> > Window.cpp -lfltk -lfltk_images
>
>       Hmm, that's an interesting command line snippet; I'm guessing
>       the book shows something like that in its text?
>
>       From the above, it would appear the app you're trying to
>       compile depends on various other files.
>
>       I'm guessing the Makefile will be the most useful thing
>       you can paste us at this point.

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to