Instead of giving lengthy compiler commands at the command prompt, you can use a Makefile to do most of the work. How to:
makefile
. census.c
, then the first line will read PROGNAME=census
). .c
files, add a corresponding .o
to the currently blank objects
variable, e.g. objects=sample2.o sample3.o
make
at the command prompt to generate the executable.pkg-config
, then you can use it for a slightly more robust and readable makefile. Replace the above C and link flags with: pkg-config
program will then fill in the appropriate directories and libraries. Pkg-config knows Apophenia depends on the GSL and database libraries, so you need only list the most-dependent library.-O3
flag is optional, asking the compiler to run its highest level of optimization (for speed).–std=gnu99
or –std=gnu11
flag to use post-1989 C standards.gcc sample.c -lapophenia
will work, while gcc -lapophenia sample.c
is likely to give you errors. Similarly, list -lapophenia
before -lgsl
, which comes before -lgslcblas
.