问题描述
试图让Gnu科学图书馆(gsl)在cygwin g ++中工作。
trying to get the Gnu Scientific Library (gsl) to work in cygwin g++.
Cygwin是使用所有默认参数安装和更新的,包括gsl:runtime,gsl-apps和gsl-doc。我正在尝试gsl网站中提供的示例程序:
Cygwin is installed and updated with all default parameters and includes gsl:runtime, gsl-apps and gsl-doc. I am trying the example program given in the gsl website:
#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;
}
任何人都会给我一个版本的上述程序实际使用g ++?该头文件无法在此默认安装中找到。我如何访问dll?
Would anyone be so kind as to give me a version of the above program that actually works with g++? The header file is nowhere to be found with this default installation. How do I access the dll?
我还试图安装非默认的'gsd-devel'(开发工具),它让我访问头文件但是当我编译时,我得到了未定义的引用'gsl__sf_bessel_J0',即使找到头文件。
I also tried to install the non-default 'gsd-devel' (the developper tools), which gives me access to the header file but when I compile I am getting "Undefined reference to 'gsl__sf_bessel_J0'", even though the header file is found.
任何帮助非常感谢! $ b
Any help greatly appreciated!
推荐答案
我是CygWin& GSL,以及我经过一番研究,我认为答案在于事实,所需的库没有被链接。有一个聪明的小工具,GSL自带的 gsl-config
。您可以使用它来获取链接信息到库。所以在你的case,代码:
I am new to CygWin & GSL as well, and I after some research, I think the answer lies in the fact that the required libraries are not being linked. There is a clever little tool which comes with GSL called gsl-config
. You can use this to get the linking information to the libraries. So in your case, the code:
#include <gsl/gsl_sf_bessel.h>
#include <stdio.h>
int
main (void)
{
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\n", x, y);
return 0;
}
可以使用 g ++ bessel.cpp -lm -lgsl -o bessel.out -L / usr / bin
其中 -lm -lgsl -L / usr / bin
位是输入 gsl-config --lib-without-cblas
。使用 ./ bessel.out
测试。
can be compiled using g++ bessel.cpp -lm -lgsl -o bessel.out -L/usr/bin
where the -lm -lgsl -L/usr/bin
bit is the output of typing gsl-config --lib-without-cblas
. Test using ./bessel.out
.
希望这有帮助,T
这篇关于使用GSL和cygwin g ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!