![]() |
|
Instead of giving lengthy GCC commands at the command prompt, you can use a Makefile to do most of the work. How to:
makefile. sample.c, then the first line will read PROGNAME=sample). .c files, just add a corresponding .o on the objects line, e.g. sample2.o sample3.o make at the command prompt to generate the executable.PROGNAME = your_program_name_here
objects =$(PROGNAME).o
CFLAGS = -g -Wall
LINKFLAGS = -lapophenia -lgsl -lgslcblas -lsqlite3
c: $(objects)
gcc $(CFLAGS) $(objects) $(LINKFLAGS) -o $(PROGNAME)
$(objects): %.o: %.c
gcc $(CFLAGS) -c $< -o $@
By the way, if your system has pkg-config, then you can use it for a slightly more robust and readable makefile. Replace the above C and link flags with:
CFLAGS = -g -Wall `pkg-config --cflags apophenia` LINKFLAGS = `pkg-config --libs apophenia`
The pkg-config program will then fill in the appropriate directories and libraries. Pkg-config knows Apophenia depends on the GSL and (if applicable) sqlite3, so you need only list the most-dependent library.