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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This error message typically occurs when you are trying to compile or link a program that depends on the GNU Scientific Library (GSL), but the necessary include files and libraries are not found. To fix this error, you need to make sure that the GSL is installed on your system and that the compiler/linker can find the necessary files. Here are some steps you can follow: 1. Install the GSL library: Depending on your operating system, you may be able to install the GSL using a package manager (e.g. apt-get, yum, brew) or by downloading and installing it manually from the GSL website. 2. Set the environment variables: Once you have installed the GSL, you need to set the environment variables GSL_INCLUDE_DIR, GSL_LIBRARY, and GSL_CBLAS_LIBRARY to the correct paths. These variables tell the compiler/linker where to find the necessary files. The exact commands to set these variables will depend on your shell and operating system. Here are some examples: - Bash (Linux/Mac): ``` export GSL_INCLUDE_DIR=/path/to/gsl/include export GSL_LIBRARY=/path/to/gsl/lib/libgsl.so export GSL_CBLAS_LIBRARY=/path/to/gsl/lib/libgslcblas.so ``` - Windows Command Prompt: ``` set GSL_INCLUDE_DIR=C:\path\to\gsl\include set GSL_LIBRARY=C:\path\to\gsl\lib\libgsl.dll set GSL_CBLAS_LIBRARY=C:\path\to\gsl\lib\libgslcblas.dll ``` 3. Compile/link your program: With the environment variables set, you should be able to compile/link your program without the missing GSL errors. Make sure to include the appropriate compiler/linker flags to link against the GSL library (e.g. -lgsl -lgslcblas). Note: If you are using a build system (e.g. CMake) to manage your project, you may need to modify the build configuration to include the necessary GSL include directories and libraries. Consult the documentation for your build system for more information.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值