Ubuntu – Altough I installed GSL library, g++ cannot compile the code

14.04ccompilinggcc

In order to use gnu gsl library I've installed it with the following command :

sudo apt-get install libgsl0ldbl

When I write a simple c++ code just to check whether I installed it correctly or not, g++ says that

fatal error: gsl/gsl_vector.h: No such file or directory

My code can be seen below :

#include <iostream>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_statistics.h>
using namespace std;
int main()
{
return 0;
}

what might be the reason ? Thanks in advance. [I'm trying to run it on ubuntu 14.04 64-Bit]

edit
I tried to compiled it with the following command

g++ test.cpp

Best Answer

There are a number of libgsl packages, as shown by an apt-cache search:

$ apt-cache search libgsl
libgsl0-dbg - GNU Scientific Library (GSL) -- debug symbols package
libgsl0-dev - GNU Scientific Library (GSL) -- development package
libgsl0ldbl - GNU Scientific Library (GSL) -- library package
libocamlgsl-ocaml - GNU scientific library for OCaml
libocamlgsl-ocaml-dev - GNU scientific library for OCaml

In more detail, apt-cache show libgsl0ldbl includes the description

 This package provides the shared libraries required to run programs
 compiled with GNU GSL. To compile your own programs you also need to
 install libgsl0-dev.

whereas apt-cache show libgsl0-dev has

 This package contains the header files, static libraries and symbolic
 links that developers using GNU GSL will need.

so in this case you need to install libgsl0-dev

sudo apt-get install libgsl0-dev

This is quite a common distinction in the Ubuntu/Debian packaging system: there is usually a "runtime" package, and a "development" package that is indicated by a -dev suffix. The -dev package is the one to look for when building software from source - it will install the runtime package as a dependency if it is required.

Related Question