使用f2c后链接
我使用 f2c 将一个巨大的 Fortran 子例程翻译为 C。标题如下:
/* fourier.f -- translated by f2c (version 20090411).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
我正在使用 ubuntu 10.04。如何将目标文件与 libf2c 链接?
I used f2c to translate a huge Fortran subroutine into C. The header says the following:
/* fourier.f -- translated by f2c (version 20090411).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
I am using ubuntu 10.04. How can I link the object file with libf2c?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须安装
libf2c2-dev
软件包 - 但由于f2c
软件包已经依赖于它,您可能需要的只是添加-lf2c 到您的 Makefile。
You would have to install the
libf2c2-dev
package -- but as thef2c
package already depends on it, all you may need is to add-lf2c
to your Makefile.您是否使用 gcc 编译生成的 C 文件?然后将“-lf2c -lm”添加到gcc编译命令中。
为什么不使用 Fortran 编译器进行编译,例如 gfortran?它可以轻松地用于 Ubuntu。
Are you compiling the resulting C file with gcc? Then add "-lf2c -lm" to the gcc compile command.
Why not compile with a Fortran compiler, such as gfortran? It's easily available for Ubuntu.
通过将
-lf2c -lm
传递到将从对象创建可执行文件的行。你在 Ubuntu 上使用哪个编译器?海湾合作委员会?可能就是这么简单。
By passing
-lf2c -lm
to the line which will create the executable from the objects. Which compiler are you using on Ubuntu? GCC?Could be as simple as that.
好吧 - 没有直接回答您的链接问题,但是:
既然您使用的是 Linux:为什么不按原样编译 fortran 代码并将其直接与 C 代码链接呢?海湾合作委员会可以做到这一点。转换代码当然是可行的,但绝不是必需的。
尼尔斯
Well - no direct answer to your linking problems, but:
Since you're working with Linux: Why don't you compile you fortran code as is and link it directly with the C-code? GCC can do that. Converting the code is of course doable but it is by no way required.
Nils