使用最新的 mingw-get-inst (3.16.11)、gcc 编译 libf2c 时出现问题
我正在尝试将一些非常旧的 Fortran 代码移植到 Windows。我想使用 mingw 和 f2c,它们可以将代码转换为 OS X 和 Ubuntu 上可用的 C 语言。我在全新安装的 mingw 上使用了由 netlib 分发的 f2c.exe,并且它很好地翻译了代码。我有一个 libf2c 的“移植”版本,它似乎仍然包含一些未解析的引用 - 主要是文件 i/o 例程(do_fio
、f_open
、s_wsfe、
e_wsfe
),特别是一个算术例程 (pow_dd
)。为了解决这些问题,我尝试从 源 构建 libf2c,但在运行过程中遇到了问题制作过程。 make 继续执行 dtime_.c
,但随后由于对 sys/times.h
的依赖而失败,该文件不再是 mingw 发行版的一部分。在 times.h
中似乎定义了一个 struct
,它定义了 dtime_.c
中变量的大小,特别是 t<第 53 行和第 54 行的 /code> 和
t0
(错误是“'t' 的存储大小未知”;t0
相同)。
makefile
已修改为使用 gcc,并且在不传递任何其他选项的情况下调用 make。
有人知道这个问题的解决方法吗?我相信,一旦我正确编译了 libf2c,我就能够将其与 gcc 链接,并且代码将像在 linux 和 os X 上一样工作。
后续:我能够通过注释掉 makefile
中与时间相关的文件来构建 libf2c.a
(我的代码不包含任何与时间相关的函数,所以不要认为这很重要)。我将其复制到非 POSIX 搜索目录,如 -print-search-dirs 中所示,特别是 C:\MinGW\lib\gcc\mingw32\3.4.5。这似乎解决了未解决的引用的问题,尽管消除时间文件的需要确实让我担心。虽然我的代码现在可以工作,但最初的问题是——如何处理在 mingw 中调用 sys/times.h 的 makefile?
I'm trying to port some very old fortran code to windows. I'd like to use mingw and f2c, which has no problem converting the code to usable C on OS X and Ubuntu. I used f2c.exe as distributed by netlib on a fresh install of mingw, and it translated the code fine. I have a "ported" version of libf2c that seems to still contain some unresolved references -- mostly file i/o routines (do_fio
, f_open
, s_wsfe
, e_wsfe
) and, peculiarly, one arithmetic routine (pow_dd
). To resolve these issues, I tried to build libf2c from source, but ran into an issue during the make process. The make proceeds to dtime_.c
, but then fails due to a dependency on sys/times.h
, which is no longer a part of the mingw distro. There appears to be a struct
defined in times.h
that defines the size of a variable in dtime_.c
, specifically t
and t0
on lines 53 and 54 (error is "storage size of 't' isn't known"; same for t0
).
The makefile
was modified to use gcc, and make invoked with no other options passed.
Might anyone know of a workaround for this issue? I feel confident that once I have a properly compiled libf2c, I'll be able to link it with gcc and the code will work like it does on linux and os X.
FOLLOW-UP: I was able to build libf2c.a
by commenting out the time related files in the makefile
(my code does not contain any time related functions, so don't think it will matter). I copied it to a non-POSIX search directory as show in -print-search-dirs, specifically C:\MinGW\lib\gcc\mingw32\3.4.5. That seems to have fixed the issue on the unresolved references, although the need to eliminate the time files does concern me. While my code is now working, the original question stands -- how to handle makefiles that call for sys/times.h
in mingw?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定 MinGW 安装正确吗?据我所知,
sys/times.h
标头仍然存在,位于mingwrt-3.18-mingw32-dev.tar.gz
包中。我不熟悉 gui 安装程序,但也许您必须勾选mingwrt dev
组件的框。Are you sure the MinGW installation went correct? As far as I can tell the
sys/times.h
header is still there, in the packagemingwrt-3.18-mingw32-dev.tar.gz
. I'm not familiar with the gui installer, but perhaps you have to tick a box for themingwrt dev
component.