From 21b66924761abd99b1b7814ab14fb2783226ed32 Mon Sep 17 00:00:00 2001 From: engelsman Date: Mon, 9 Mar 2009 20:58:27 +0000 Subject: basics.dox: added example Makefile using fltk-config (STR #2149) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6673 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/src/basics.dox | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'documentation/src') diff --git a/documentation/src/basics.dox b/documentation/src/basics.dox index bbe94756c..b22b7494c 100644 --- a/documentation/src/basics.dox +++ b/documentation/src/basics.dox @@ -289,6 +289,44 @@ fltk-config --use-forms --use-gl --use-images --compile filename.cpp Any of these will create an executable named filename. +\section basics_makefile Compiling Programs with Makefiles + +The previous section described how to use fltk-config to +build a program consisting of a single source file from the command +line, and this is very convenient for small test programs. +But fltk-config can also be used to set the compiler and +linker options as variables within a Makefile that can be +used to build programs out of multiple source files: + +\code +CXX = $(shell fltk-config --cxx) +DEBUG = -g +CXXFLAGS = $(shell fltk-config --use-gl --use-images --cxxflags ) -I. +LDFLAGS = $(shell fltk-config --use-gl --use-images --ldflags ) +LDSTATIC = $(shell fltk-config --use-gl --use-images --ldstaticflags ) +LINK = $(CXX) + +TARGET = cube +OBJS = CubeMain.o CubeView.o CubeViewUI.o +SRCS = CubeMain.cxx CubeView.cxx CubeViewUI.cxx + +.SUFFIXES: .o .cxx +%.o: %.cxx + $(CXX) $(CXXFLAGS) $(DEBUG) -c $< + +all: $(TARGET) + $(LINK) -o $(TARGET) $(OBJS) $(LDSTATIC) + +$(TARGET): $(OBJS) +CubeMain.o: CubeMain.cxx CubeViewUI.h +CubeView.o: CubeView.cxx CubeView.h CubeViewUI.h +CubeViewUI.o: CubeViewUI.cxx CubeView.h + +clean: $(TARGET) $(OBJS) + rm -f *.o 2> /dev/null + rm -f $(TARGET) 2> /dev/null +\endcode + \section basics_visual_cpp Compiling Programs with Microsoft Visual C++ In Visual C++ you will need to tell the compiler where to -- cgit v1.2.3