The -c
switch tells gcc to compile source code to binary object code, but not link it to create an executable program: you will first need to remove that:
gcc -Wall -I/usr/local/include sample_matrix.c
You will then likely find there are lots of undefined reference to ...
errors, because you haven't specified the relevant libraries to link on the command line. (Header files only declare things; libraries define them). If you have installed gsl
in a standard location like /usr/local
, then it should have placed a .pc
file in /usr/local/lib/pkgconfig/
that will allow you to automate the specification of libraries using pkg-config
ex.
gcc -Wall -I/usr/local/include sample_matrix.c `pkg-config --libs gsl`
(note the order of arguments: references are resolved from left to right). You can probably use pkg-config
to locate the header files as well i.e.
gcc -Wall sample_matrix.c `pkg-config --cflags --libs gsl`
-c
switch tells gcc to compile source code to binary object code, but not link it to create an executable program. You will need to remove that and also likely need to specify the gsl (and any other required) libraries (for examplepkg-config --libs gsl
)