Fortran到C库的链接器错误 - /usr/lib/libf2c.so:未定义对'MAIN__'的引用 [英] Linker errors with Fortran to C library - /usr/lib/libf2c.so: undefined reference to 'MAIN__'

查看:555
本文介绍了Fortran到C库的链接器错误 - /usr/lib/libf2c.so:未定义对'MAIN__'的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在Fortran中遇到了一些C库问题。现在,在我解决问题之前,我可以告诉你,我不能像一些论坛网站所建议的那样使用g2c。



现在解决问题。当我尝试编译一个非常大的项目时,我得到以下内容:

$ p $ [来自makefile ...] g ++ -L [〜200 dirs] -l [〜200 libs] -lf2c
/usr/lib/libf2c.so:未定义引用'MAIN__'
collect2:ld返回1退出状态
make: *** [all]错误1

现在,我已经检查了我的 /

  $ locate libf2c 
/usr/lib/libf2c.so
/usr/lib/libf2c.so.0
/usr/lib/libf2c.so.0.22

所以至少它在那里。我用google,告诉我进入...

  sudo rm /usr/lib/libf2c.so&& amp ; sudo ln -s /usr/lib/libf2c.a /usr/lib/libf2c.so 

。 ..有助于。关于图书馆的旧意味着海湾合作委员会不再正确地链接到它,并试图找到一个没有的方法。所以我做到了。但是,在链接到.a库之后,g ++现在根本找不到该库。


$ b $

  g ++ -L [〜200 dirs] -l [〜200 libs] -lf2c 
/ usr / bin / ld:找不到-lf2c
collect2:ld返回1退出状态
make:*** [全部]错误1

所以实际上我已经倒退了。任何人有什么想法,我应该从哪里出发?



编辑:所以我想我明白了。我遵循到重新安装库。现在它神奇地不抱怨fortran主要不存在。感谢您的帮助。

解决方案

您应该更加关注第一条错误消息。链接器告诉你,没有符号 MAIN __ 可以找到,这就是f2c预计fortran main将被编译到你的C或C ++代码中。 f2c库本身工作得很好。



原始错误的解决方案是确保在您的代码中定义了正确的入口点。这可能是通过使用C ++进行编译,你有名称修改问题,并且f2c库的正确入口点不存在。



现在通过混淆f2c库,你已经完全破坏了你的f2c安装。重新安装并重新开始...


So I'm having a little trouble with the fortran to C library. Now, before I get into the problem, I can tell you that I cannot use g2c as some forum sites have suggested.

Now, to the problem. When I try to compile a very large project, I get the following:

[from the makefile...] g++ -L [~200 dirs] -l [~200 libs] -lf2c  
/usr/lib/libf2c.so: undefined reference to 'MAIN__'  
collect2: ld returned 1 exit status  
make: *** [all] Error 1

Now, I have checked my /usr/lib directory and have come up with the following:

$ locate libf2c
/usr/lib/libf2c.so
/usr/lib/libf2c.so.0
/usr/lib/libf2c.so.0.22

So at the very least, it is there. I used the google, which told me that entering...

sudo rm /usr/lib/libf2c.so && sudo ln -s /usr/lib/libf2c.a /usr/lib/libf2c.so

...would help. Something about the oldness of the library meaning that gcc doesn't link to it right anymore, and tries to find a main method where there isn't one. So I did it. However, after I linked to the .a library, g++ now can't find the library at all.

g++ -L [~200 dirs] -l [~200 libs] -lf2c 
/usr/bin/ld: cannot find -lf2c
collect2: ld returned 1 exit status
make: *** [all] Error 1

So in effect I've gone backwards. Anyone have any ideas as to where I should go from here?

EDIT: So I think I figured it out. I followed this to reinstall the libs. Now it magically does not complain that the fortran main doesn't exist. Thanks for your help guys.

解决方案

You should have paid closer attention to the first error message. The linker is telling you that no symbol MAIN__ can be found, which is what f2c is expected that the fortran main will be compiled to in your C or C++ code somewhere. The f2c library itself was working just fine.

The solution to the original error would be to make sure the correct entry point is defined in your code. It might be that by using C++ to compile, you have name mangling problems and the correct entry point for the f2c library doesn't exist.

Now by messing around with the f2c libraries, you have totally broken your f2c installation. Reinstall it and start again...

这篇关于Fortran到C库的链接器错误 - /usr/lib/libf2c.so:未定义对'MAIN__'的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆