|
CAPD::DynSys Library
6.0.0
|
To build your own programs we recommend use of attached script that are generated according to your system configuration. It provides compiler flags (parameter -—cflags ) or/and linker flags with all necessary dependencies (parameter -—libs).
After successful building the library the script is located in bin sudirectory.
After call
this script is installed into <prefix>/bin directory. We assume that this location is on the search path of your system so that scripts can be called by its name (if not in the example below you need to provide full path to them).
Assume that you want to build your MyProgram.cpp that uses double version of CAPD.
Then the instruction might be something like
if g++ is your C++ compiler and you want configuration from capd-config.
-std=c++17 -O2 options. Both flags are returned by -—cflagsIt is possible to compile your program without our scripts. But then command line strongly depends on your system configuration.
Assume that the CAPD library was installed to /home/user/capd and it uses intervals from filib library then the instruction might be
-frounding-math compiler can optimize code so that it is not rigorous anymore. Proper options for current configuration are returned by capd-config -—cflags.
The example can be found in capd/capdMake/examples/projectStarter directory.
Assume that in the some directory we have project that contains:
/home/user/capdTo compile all source files create in the project directory a file Makefile that contains the following code (all indents need to be made by tabulators not spaces!!!)
# a list of all the programs in your project
PROGS = MyProgram YourProgram
# a list of all your units to be linked with your programs (space separated)
OTHERS = utils output
# path to directory, where script capd-config is located
CAPDBINDIR =/home/user/capd/build/bin/
# setting compiler and linker flags
CAPDCXX := $(shell $(CAPDBINDIR)capd-config --variable=capd_cxx)
CAPDFLAGS = `${CAPDBINDIR}capd-config --cflags`
CAPDLIBS = `${CAPDBINDIR}capd-config --libs`
CXXFLAGS += ${CAPDFLAGS}
# directory where object and dependancy files will be created
OBJDIR = .obj/
#============ the following should not be changed =========
OTHERS_OBJ = ${OTHERS:%=${OBJDIR}%.o}
OBJ_FILES = ${OTHERS_OBJ} ${PROGS:%=${OBJDIR}%.o}
.PHONY: all
all: ${PROGS}
# rule to link executables
${PROGS}: % : ${OBJDIR}%.o ${OTHERS_OBJ}
${CAPDCXX} -o $@ $< ${OTHERS_OBJ} ${CAPDLIBS}
# include files with dependencies
-include ${OBJ_FILES:%=%.d}
#rule to compile .cpp files and generate corresponding files with dependencies
${OBJ_FILES}: ${OBJDIR}%.o : %.cpp
@mkdir -p ${OBJDIR}
$(CAPDCXX) ${CXXFLAGS} -MT $@ -MD -MP -MF ${@:%=%.d} -c -o $@ $<
# rule to clean all object files, dependencies and executables
.PHONY: clean
clean:
rm -f ${OBJDIR}*.o ${OBJDIR}*.o.d ${PROGS}
Then by calling make you will compile all source files and link all programs defined by PROGS variable. It will also create a list of dependencies (list of header files that it uses) for each source file so that next time source file will be recompiled only if itself or some of its dependencies has changed.