我已经在Kubuntu14.04中安装了GSL的最新版本(1.16)。在安装时,我使用库附带的文件安装(一步一步)。我将eclipse环境配置为使用它。它可以工作,我认为,因为有一个自动完成,但当我开始编译程序时,会出现一些错误。拜托,我怎么才能修好它?
对不起我的英语不好!文件math.c有#include
Building target: C
Invoking: GCC C Linker
gcc -L/usr/local/lib -o "C" ./src/C.o -lgsl -lgslcblas
/usr/local/lib/libgsl.a(math.o): In function `gsl_complex_polar':
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:56: undefined reference to `sincos'
/usr/local/lib/libgsl.a(math.o): In function `gsl_complex_logabs':
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:115: undefined reference to `log'
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:115: undefined reference to `log1p'
/usr/local/lib/libgsl.a(math.o): In function `gsl_complex_abs':
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:83: undefined reference to `hypot'
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:83: undefined reference to `hypot'
/usr/local/lib/libgsl.a(math.o): In function `gsl_complex_sqrt':
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:293: undefined reference to `sqrt'
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:293: undefined reference to `sqrt'
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:288: undefined reference to `sqrt'
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:288: undefined reference to `sqrt'
/home/hacker101/Project/Libraries/gsl-1.16/complex/math.c:293: undefined reference to `sqrt'
......
collect2: error: ld returned 1 exit status
make: *** [C] Error 1 发布于 2014-10-03 20:47:15
这很可能只是数学库的一个缺失链接。您可能想尝试将-lm添加到链接命令的-lgsl -lgslcblas之后。
https://stackoverflow.com/questions/26186501
复制相似问题