change the order of the gcc line to: gcc sampling.c -std=c99 -lgsl -lgslcblas -lm -O2 -o sampling as the old order might fail to search for the libs