ubuntu系统下,gsl 库链接问题 -undefined reference to `cblas_xxx`

  今天在ubuntu系统下进行程序调试的时候出现以下错误信息:

[ 10%] Linking CXX executable ../test_coco
/usr/local/lib/libgsl.so: undefined reference to `cblas_ztrsv'
/usr/local/lib/libgsl.so: undefined reference to `cblas_scasum'
/usr/local/lib/libgsl.so: undefined reference to `cblas_izamax'
/usr/local/lib/libgsl.so: undefined reference to `cblas_dnrm2'
/usr/local/lib/libgsl.so: undefined reference to `cblas_zdotc_sub'

collect2: error: ld returned 1 exit status
make[2]: *** [test_coco] Error 1
make[1]: *** [src/CMakeFiles/test_coco.dir/all] Error 2
make: *** [all] Error 2

  可以看出,之前的编译都没有问题,在最后的链接阶段出现错误,根据提示可知,libgsl库链接相关文件的时候出现问题。libgsl库依赖clbas库中的相关文件。所以在链接gls后还需加上对gslcblas的链接,问题解决!

原文地址:https://www.cnblogs.com/bozhicheng/p/5644582.html