Compilation 带GSL的稀疏矩阵-编译错误

Compilation 带GSL的稀疏矩阵-编译错误,compilation,sparse-matrix,gsl,Compilation,Sparse Matrix,Gsl,我正在测试GNU科学库(GSL),我想用它创建一个稀疏矩阵。这是我的代码,直接来自: 结果是: /tmp/ccyBfp0p.o: In function `main': test1.c:(.text+0x13): undefined reference to `gsl_spmatrix_alloc' test1.c:(.text+0x40): undefined reference to `gsl_spmatrix_set' test1.c:(.text+0x69): undefined

我正在测试GNU科学库(GSL),我想用它创建一个稀疏矩阵。这是我的代码,直接来自:

结果是:

 /tmp/ccyBfp0p.o: In function `main':
 test1.c:(.text+0x13): undefined reference to `gsl_spmatrix_alloc'
 test1.c:(.text+0x40): undefined reference to `gsl_spmatrix_set'
 test1.c:(.text+0x69): undefined reference to `gsl_spmatrix_set'
 test1.c:(.text+0x87): undefined reference to `gsl_spmatrix_set'
 test1.c:(.text+0xb0): undefined reference to `gsl_spmatrix_set'
 test1.c:(.text+0xd9): undefined reference to `gsl_spmatrix_set'
 /tmp/ccyBfp0p.o:test1.c:(.text+0x102): more undefined references to    `gsl_spmatrix_set' follow
 /tmp/ccyBfp0p.o: In function `main':
 test1.c:(.text+0x189): undefined reference to `gsl_spmatrix_get'
 test1.c:(.text+0x25d): undefined reference to `gsl_spmatrix_compcol'
 test1.c:(.text+0x39b): undefined reference to `gsl_spmatrix_free'
 test1.c:(.text+0x3a7): undefined reference to `gsl_spmatrix_free'
 collect2: error: ld returned 1 exit status
然后我尝试使用以下代码进行编译:

 gcc -I/usr/local/include/gsl -L/usr/local/lib -o test test1.c -lgsl -lgslcblas -lm
这编译了代码,没有错误,但当我尝试运行它时,出现了以下错误:

 ./test: error while loading shared libraries: libgsl.so.19: cannot open shared object file: No such file or directory
但当我这样做的时候:

 ls /usr/local/lib
我可以看到结果:

 libemon.a       libgslcblas.so        libgsl.so         python2.7
 libgsl.a        libgslcblas.so.0      libgsl.so.19      python3.4
 libgslcblas.a   libgslcblas.so.0.0.0  libgsl.so.19.1.0  site_ruby
 libgslcblas.la  libgsl.la             pkgconfig

我想我的GSL安装有问题。但问题是,所有其他的计算都很好!只有稀疏矩阵给了我这个问题

如下更新
$LD_LIBRARY_PATH
是否修复加载共享库时的
错误


export LD\u LIBRARY\u PATH=/usr/local/lib:$LD\u LIBRARY\u PATH

您确定您安装的GSL版本支持稀疏阵列吗?您使用的是什么版本的GSL?(使用宏
GSL\u版本
GSL\u主要版本
GSL\u次要版本
 ls /usr/local/lib
 libemon.a       libgslcblas.so        libgsl.so         python2.7
 libgsl.a        libgslcblas.so.0      libgsl.so.19      python3.4
 libgslcblas.a   libgslcblas.so.0.0.0  libgsl.so.19.1.0  site_ruby
 libgslcblas.la  libgsl.la             pkgconfig