虽然我安装了 GSL 库,但 g++ 无法编译我的代码

sta*_*low 7 compiling gcc c++ 14.04

为了使用 gnu gsl 库,我使用以下命令安装了它:

须藤 apt-get 安装 libgsl0ldbl

当我编写一个简单的 c++ 代码只是为了检查我是否正确安装它时,g++ 说

致命错误:gsl/gsl_vector.h:没有那个文件或目录

我的代码可以在下面看到:

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

可能是什么原因?提前致谢。[我正在尝试在 ubuntu 14.04 64 位上运行它]

编辑 我尝试使用以下命令编译它

g++ 测试.cpp

ste*_*ver 11

有许多 libgsl 包,如以下所示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
Run Code Online (Sandbox Code Playgroud)

更详细地,apt-cache show libgsl0ldbl包括描述

 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.
Run Code Online (Sandbox Code Playgroud)

apt-cache show libgsl0-dev

 This package contains the header files, static libraries and symbolic
 links that developers using GNU GSL will need.
Run Code Online (Sandbox Code Playgroud)

所以在这种情况下你需要安装 libgsl0-dev

sudo apt-get install libgsl0-dev
Run Code Online (Sandbox Code Playgroud)

这是 Ubuntu/Debian 打包系统中相当常见的区别:通常有一个“运行时”包和一个由-dev后缀表示的“开发”包。该-dev包是从源代码构建软件时要查找的包 - 如果需要,它将安装运行时包作为依赖项。