让 Gnu 科学图书馆在 Cygwin 中工作
我正在使用 gsl 和 Cygwin,并且首先我尝试编译一个非常简单的程序(稍后我将从 Fortran 程序中调用它)。由于定位 gsl 文件出现问题,我无法编译它。代码是:
#include <gsl/gsl_math.h>
void gslgateway_(double *x, double *res){
*res = gsl_atanh(*x);
}
当我尝试通过以下方式编译它时:
gcc -c gslgateway.c
我收到以下错误:
gslgateway.c:1:26: error: gsl/gsl_math.h: No such file or directory
如果我将第一行更改为
#include <C:/cygwin/usr/include/gsl/gsl_math.h>
然后找到 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
...
所以,问题似乎是路径到库文件。但尽我所能,我似乎无法正确设置它。我按照 Using GSL with cygwin g++ 的建议使用了 gsl-config ,它给了我
-L/usr/include
这样我尝试使用它作为选项进行编译,但得到了相同的结果。我还尝试将 LD_LIBRARY_PATH 设置为 /usr/lib、/usr/include、C:/cygwin/usr/include 和其他几个组合,但没有任何效果。
我现在不知道还能尝试什么。谁能看到我缺少什么吗?
(其他信息:我安装了 gsl-devel。至少,我要求 Cygwin 安装程序安装它,并且我可以找到一个文件夹 /usr/include/gsl,其中包含 gsl_math.h 以及许多其他文件。我不知道如果还有什么我需要在那里做的话。)
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). I am unable to get it compile due to problems locating the the gsl files. 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:
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
-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.
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.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我的猜测似乎是正确的,因此我将其作为答案发布。
看起来您正在使用 MinGW 编译器。 MinGW 不是 Cygwin 的一部分,因此它不理解 Cygwin 风格的路径。这就是为什么您的编译器能够找到
C:/cygwin/usr/include/
但找不到/usr/include
。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 isn't part of Cygwin, so it doesn't understand Cygwin-style paths. That's why your compiler was able to find
C:/cygwin/usr/include/
but not/usr/include
.