I was able to test both 1.4.0 and 1.3.5 and compile both with one command and the Makefile
I created a file with the summary of this post, but I can't attach it so I'll post it below.
Maybe it's worth adding it on Github to help other beginners like me who maybe come from Dr. S book
and have no idea where to install, how to install or how to compile with Makefiles.
##################################### FLTK install & use ################################################################
download FLTK in the home folder:
git clone https://github.com/fltk/fltk.git fltk-1.4.0
the following sequence will install FLTK in the home path (/home/ken01/dev/fltk-1.4.0)
installing FLTK in the home path is preferable when you want to test multiple versions
in the/home/ken01/dev/fltk-1.4.0 folder:
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/home/ken01/dev/fltk-1.4.0 -D 'CMAKE_BUILD_TYPE=Debug' -D FLTK_BUILD_EXAMPLES=ON ..
make
make install
while this will install FLTK on the system (the default path is /usr/local or /usr)
mkdir build
cd build
cmake -D 'CMAKE_BUILD_TYPE=Debug' -D FLTK_BUILD_EXAMPLES=ON ..
make
make install
for those coming from Programming Principles and Practice
when you want to compile a program that uses FLTK you can use either
this command:
g++ -w -Wall -std=c++14 Graph.cpp Window.cpp GUI.cpp Simple_window.cpp 13.12_circle.cpp `/home/ken01/dev/fltk-1.4.0/bin/fltk-config --cxxflags --ldflags --use-images` -o 13.12_circle.bin
or a Makefile:
(for more complex programs)
################ template makefile ##############
# Set up the paths to the folders we will read files from
PATH_1 := /path/to/some/files
PATH_2 := /path/to/other/files
# Where is the fltk-config we plan to use?
FLTK_CNF := /full/path/to/my/fltk-config
# We don't know what compiler to use to build fltk on this machine - but fltk-config does...
CC := $(shell $(FLTK_CNF) --cc)
CXX := $(shell $(FLTK_CNF) --cxx)
# Set the flags for compiler: fltk-config knows the basic settings, then we can add our own...
CFLAGS := $(shell $(FLTK_CNF) --cflags) -Wall -O3 -I$(PATH_1) -I$(PATH_2)
CXXFLAGS := $(shell $(FLTK_CNF) --cxxflags) -Wall -O3 -I$(PATH_1) -I$(PATH_2)
# We don't know what libraries to link with: fltk-config does... Throw in the kitchen sink...
LINKFLTK := $(shell $(FLTK_CNF) --use-gl --use-images --ldstaticflags)
# Possible steps to run after linking...
STRIP := strip
POSTBUILD := $(FLTK_CNF) --post # May be required on OSX (does nothing on other platforms, so safe to call)
# Define what your target application is called
TARGET := MyApp
# What objects go into the target application
OBJECTS := file1.o file2.o
all: $(TARGET)
# Define how to build the various object files...
file1.o: $(PATH_1)/file1.c $(PATH_1)/file1.h # a "plain" C file from PATH_1
$(CC) -c $< -o $@ $(CCFLAGS)
file2.o: $(PATH_2)/file2.cxx $(PATH_2)/file2.h $(PATH_1)/file1.h # a C++ source file from PATH_2
$(CXX) -c $< -o $@ $(CXXFLAGS)
# Now define how to link the final app
MyApp: $(OBJECTS)
$(CXX) -o $@ $(OBJECTS) $(LINKFLTK)
$(STRIP) $@
$(POSTBUILD) $@ # only required on OSX, but we call it anyway for portability
clean:
rm -f $(TARGET)
rm -f $(OBJECTS)
############### end #################