简体   繁体   English

让Gnu科学图书馆在Cygwin中工作

[英]Getting the Gnu Scientific Library to work in Cygwin

I'm using gsl and Cygwin, and to get started I am trying to compile a very simple program (which I will later call from a Fortran program). 我正在使用gsl和Cygwin,要开始使用,我正在尝试编译一个非常简单的程序(稍后将在Fortran程序中调用该程序)。 I am unable to get it compile due to problems locating the the gsl files. 由于找不到gsl文件,我无法对其进行编译。 The code is: 代码是:

#include <gsl/gsl_math.h>

void gslgateway_(double *x, double *res){
   *res = gsl_atanh(*x);
}

When I try to compile it by: 当我尝试通过以下方式进行编译时:

gcc -c gslgateway.c

I get the following error: 我收到以下错误:

gslgateway.c:1:26: error: gsl/gsl_math.h: No such file or directory

If I change the first line to 如果我将第一行更改为

#include <C:/cygwin/usr/include/gsl/gsl_math.h>

then gsl_math.h is found, but a bunch of other files are not: 然后找到gsl_math.h,但是找不到其他文件:

In file included from gslgateway.c:1:
C:/cygwin/usr/include/gsl/gsl_math.h:23:25: error: gsl/gsl_sys.h: No such file or directory
...

So, the problem seems to be the path to the library files. 因此,问题似乎出在库文件的路径上。 But try as I might, I can't seem to set this correctly. 但是,请尝试尝试,似乎无法正确设置此设置。 I used gsl-config as suggested at Using GSL with cygwin g++ and it gives me 我按照与cygwin g ++一起使用GSL的建议使用了gsl-config,它给了我

-L/usr/include

so I tried compiling using that as an option, but I get the same result. 所以我尝试将其用作选项进行编译,但得到的结果相同。 I've also tried setting LD_LIBRARY_PATH to /usr/lib, /usr/include, C:/cygwin/usr/include and several other combinations but nothing works. 我还尝试将LD_LIBRARY_PATH设置为/ usr / lib,/ usr / include,C:/ cygwin / usr / include以及其他几种组合,但是没有用。

I don't know what else to try now. 我不知道现在还能尝试什么。 Can anyone see what I'm missing? 谁能看到我所缺少的吗?

(Other info: I have gsl-devel installed. At least, I asked the Cygwin Installer to install it, and I can find a folder /usr/include/gsl that contains gsl_math.h amongst many other files. I don't know if there's anything else I need to do there.) (其他信息:我已经安装了gsl-devel。至少,我要求Cygwin安装程序进行安装,并且我可以找到一个文件夹/ usr / include / gsl,其中包含gsl_math.h和许多其他文件。我不知道如果还有什么我需要做的。)

Since my guess appears to have been correct, I'll post it as an answer. 由于我的猜测似乎是正确的,因此我将其发布为答案。

It looks like you're using the MinGW compiler. 看来您正在使用MinGW编译器。 MinGW isn't part of Cygwin, so it doesn't understand Cygwin-style paths. MinGW不是Cygwin的一部分,因此它不了解Cygwin样式的路径。 That's why your compiler was able to find C:/cygwin/usr/include/ but not /usr/include . 这就是为什么您的编译器能够找到C:/cygwin/usr/include/而不能找到/usr/include

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM