How to install GSL on ubuntu

3 篇文章 0 订阅
1 篇文章 0 订阅


本人系统ubuntu 10.04 LTS,安装的gsl的版本是gsl 1.15,本人已经测试通过,安装成功。


The GNU Scientific Library is an open source (GPL) library of useful routines for scientific and numerical computing. It will (should) build on ony system with an ANSI C compiler.

Using GSL on the department Linux machines
I did this istallation on atlas, which is running Linux on Intel and has gcc installed. Results may (but shouldn't) be different on one of the Sun machines like zeus.

the current version of GSL and place the file in your home directory. This tutorial assumes version 1.7, so change filenames as appropriate.
Unpack the file with the following command:

tar -zxvf gsl-1.7.tar.gz
This will create a directory called gsl-1.7 in your home directory. Change to this directory.
cd gsl-1.7
The next step is to configure the installation and tell the system where to install the files. I have a directory called "dev" in my home directory that I use for this sort of thing. These instructions will install the files in the directory /home/steve/dev.

First, create the dev directory.

mkdir /home/steve/dev
Now configure the installation and tell it to use your new directory. This step may take a minute.
./configure --prefix=/home/steve/dev
If there are no errors, compile the library. This step will take several minutes.
make
Now it is a good idea to test the library before actually installing it. Again, this step will take some time.
make check
If there are no errors, go ahead and install the library.
make install
Now we can write a test program to see if the library works. Create the following program and name it example.c
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int
main (void)
{
    double x = 5.0;
    double y = gsl_sf_bessel_J0 (x);
    printf ("J0(%g) = %.18e/n", x, y);
    return 0;
}
Compile and link the program with the following commands (but use the correct path for your username):
gcc -Wall -I/home/steve/dev/include -c example.c
gcc -L/home/steve/dev/lib example.o -lgsl -lgslcblas -lm
Now try running your program!
./a.out
You should get the following output:
J0(5) = -1.775967713143382920e-01
Now that you have the GSL installed, you can remove the gsl-1.7 directory that was created in your home directory.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值