(转载)Ubuntu 安装GNU Scientific library(GSL)
背景:
Blei的hlda的C语言实现需要使用C语言的科学计算包GSL,因此决定安装。由于在windows下安装极其繁琐,先在Linux上安装之。
系统环境:
gsl安装过程
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
一个是libgslcblas.so,libgsl.so的位置很重要,编译后的文件被扔到了这里,比如 /usr/local/lib;另一个重要的位置是
- #include <stdio.h>
- #include <gsl_rng.h>
- #include <gsl_randist.h>
- int main (int argc, char *argv[])
- {
- /* set up GSL RNG */
- gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937);
- /* end of GSL setup */
- int i,n;
- double gauss,gamma;
- n=atoi(argv[1]);
- for (i=0;i<n;i++)
- {
- gauss=gsl_ran_gaussian(r,2.0);
- gamma=gsl_ran_gamma(r,2.0,3.0);
- printf("%2.4f %2.4f\n", gauss,gamma);
- }
- return(0);
- }
(1)第一反应是直接 gcc gsl_test.c
显示错误是:gsl_test.c:2: fatal error: gsl_rng.h: 没有那个文件或目录
(2)这个错误是说没有找到头文件,然后加上头文件的位置,gcc -I/usr/local/include/gsl gsl_test.c
显示错误是:gsl_test.c:(.text+0x12): undefined reference to `gsl_rng_mt19937' ...
(3)这个错误是说没有找到gsl_rng_mt19937的定义,查看了http://www.daniweb.com/software-development/cpp/threads/289812/cant-link-gsl-properly,这里说需要加上-lgsl,即链接到gsl,找到 libgsl.so.
使用命令:gcc -I/usr/local/include/gsl -lgsl gsl_test.c
(4)显示错误是://usr/local/lib/libgsl.so: undefined reference to `cblas_ctrmv'
查看了http://sourceware.org/ml/gsl-discuss/2003-q2/msg00123.html,是说错误是由于没有链接libgslcblas.so引起的,再加上-lgslcblas可以解决问题。
使用命令:gcc -I/usr/local/include/gsl -lgsl -lgslcblas gsl_test.c。
或者命令:gcc -I/usr/local/include/gsl -L/usr/local/lib -lgsl -lgslcblas gsl_test.c
(5)实测需要以下命令: gcc -I/usr/local/include/gsl gsl_test.c -lgsl -lgslcblas
这个时候出现了产出物a.out。
(5)运行a.out
./a.out 出现错误“段错误”
(6)查看源文件,发现还需要输入参数
./a.out 10
结果是:
0.2678 6.9645
3.3488 1.6894
1.9950 2.1575
-4.7934 6.1648
-0.0782 4.0292
1.7871 11.6031
-2.5931 7.7629
0.3634 1.3344
-1.0965 11.1658
0.0142 3.5412
彻底搞定,done#
转自:http://blog.csdn.net/Waleking/article/details/8265008
由于论文数据处理的需要,需要使用libeemd这个包,需要安装gsl科学库,windows下没有办法,只能转战ubuntu进行科学计算。
GSL(GNU Scientific Library)作为三大科学计算库之一,除了涵盖基本的线性代数,微分方程,积分,随机数,组合数,方程求根,多项式求根,排序等,还有模拟退火,快速傅里叶变换,小波,插值,基本样条,最小二乘拟合,特殊函数等
当然最希望通过命令来安装GSL科学库。
方法一:
GSL源码包提供了以下二进制包:
- gsl-bin:GNU Scientific Library (GSL) -- binary package
- libgsl0-dbg: GNU Scientific Library (GSL) -- debug symbols package
- libgsl0-dev: GNU Scientific Library (GSL) -- development package
- libgsl0ldbl: GNU Scientific Library (GSL) -- library package
终端键入以下命令即可安装:
sudo apt-get install libgsl0ldbl
说明:根据不同的需要选择安装不同的版本,使用 gsl-bin 将会安装所有的内容(gsl - bin 依赖 libgsl0ldbl)
方法二:
ubuntu自己编译源码(使用gsl1.6,windows上太麻烦折腾),解压后进入目录,执行:
./configure
make
make install
这个过程需要几分钟。这里还有一点需要注意的是,执行 make install 时,会自动将动态库和头文件分别拷贝到/usr/local/lib和 /usr/local/include 下面,但如果这两个目录没有写权限,就无法创建此二目录,导致安装失败,此时改用 sudo make install或者手动去赋予权限,便能解决此问题。
说明:折腾一圈还是使用前者成功的。
sudo apt-get install libgsl0-dev
参考
- http://www.lancezhange.com/2014/10/24/gsl-in-practice/
- http://www.cnblogs.com/nju2014/p/5334928.html
(转载)Ubuntu 安装GNU Scientific library(GSL)的更多相关文章
- Ubuntu 安装GNU Scientific library(GSL)
注: 此系列为自己之前所搭建网站内容. 由于论文数据处理的需要,需要使用libeemd这个包,需要安装gsl科学库,windows下没有办法,只能转战ubuntu进行科学计算. GSL(GNU Sci ...
- Visual Stdio 环境下使用 GSL (GNU Scientific Library)
Visual Stdio 环境下使用 GSL (GNU Scientific Library) 经測试.这里的方法不适用于VS2015. * 这篇文章有点过时了.建议从以下网址下载能够在 vs 环境下 ...
- 【C++】GSL(GNU Scientific Library) 的安装及在 Visual Studio 2017 中的使用
GSL 是 GNU 开发并维护的科学计算的库,其中包括: 复数 多项式的根 特殊函数 向量和矩阵 排列 排序 BLAS支持 线性代数 Eigensystems 快速傅立叶变换 正交 随机数 准随机序列 ...
- GNU scientific library
GNU scientific library 是一个强大的C,C++数学库.它涉及的面很广,并且代码效率高,接口丰富.正好最近做的一个项目中用到多元高斯分布,就找到了这个库. GNU scientif ...
- [转载]Ubuntu安装配置 git 服务器和客户端
原文地址:Ubuntu安装配置 git 服务器和客户端作者:ding404 1.配置前准备 服务器:安装ssh server另外还装了gitosis做git的权限管理 sudo apt-get ins ...
- [转载]Ubuntu 安装 万能五笔 输入法
原文地址:Ubuntu 安装 万能五笔 输入法作者:庖丁解牛 paul@paul-desktop:~/scripts$ cat ins-ibus-wnwb.sh #!/bin/sh set -e cd ...
- GSL--GNU Scientific Library 小记
摘自http://qianjigui.iteye.com/blog/847612 GSL(GNU Scientific Library)是一个 C 写成的用于科学计算的库,下面是一些相关的包 Desi ...
- 转载:安装Ubuntu 15.10后要做的事
转载:安装Ubuntu 15.10后要做的事 原文转载于:http://blog.csdn.net/skykingf/article/details/45267517 Ubuntu 15.10发布了, ...
- ubuntu安装nginx时提示error: the HTTP rewrite module requires the PCRE library
ubuntu安装nginx时提示error: the HTTP rewrite module requires the PCRE library 须要安装pcre包. sudo apt-get upd ...
随机推荐
- 在 sql 语句出现 warning 之后,立刻执行 `show warnings;` 就可以看到 warning 提示信息
在 sql 语句出现 warning 之后,立刻执行 show warnings; 就可以看到 warning 提示信息
- FTP文件传输服务
FTP文件传输服务 一 .FTP 连接及传输的模式 l 控制连接:TCP21,用于发送FTP命令信息. l 数据连接:TCP 20, 用于上传下载数据. · 数据连接建立的类型: ·主动模式: 服 ...
- google的protobuf简单介绍
google的protobuf是一种轻便高效的结构化数据存储格式,在通信协议和数据存储等领域中使用比较多.protobuf对于结构中的每个成员,会提供set系列函数和get系列函数. 但是,对于使用来 ...
- 查看Linux内置命令和外部命令
1. [hl@localhost ~]$ which cd /bin/cd [hl@localhost ~]$ type cd cd is a shell builtin
- ffmpeg 编译
下载FFmpeg git clone https://git.ffmpeg.org/ffmpeg.git 配置编译FFmpeg ./configure --prefix=host --enable-s ...
- FragmentTabHost切换Fragment时保存状态,避免切换Fragment走onCreateView和onDestroyView方法;
FragmentTabHost这个控件每次切换Fragment,都会走Fragment的onCreateView和onDestroyView方法,多以每次切换都会创建和销毁Fragment实例,先来看 ...
- JavaSE中的小知识点分析
1.System.out.println(); 调用System类中的public static final PrintStream out,输出为PrintStream(字节形式的输出流,为Outp ...
- python-web自动化环境安装
web自动化环境安装 1.安装selenium 命令行使用以下命令安装selenium:pip install -U selenium 2.安装chrome浏览器 3.chromedriver的下载 ...
- django session 的简单操作
#!SESSION_SAVE_EVERY_REQUEST = True 设置根据最后一次操作设置登录超时时间#!SESSION_EXPIRE_AT_BROWSER_CLOSE = True 设置是否关 ...
- 调整iframe滚动条失效
1:<iframe scrolling="auto" frameborder="0" src="' + add + '" style= ...