使用静态链接对象中的模块 (Fortran)

发布于 2024-12-24 18:44:46 字数 630 浏览 4 评论 0原文

亲爱的 stackoverflow 专家,

我想(使用 FORTRAN)创建一个共享对象文件,比如说 myso.so。在这个 .so 中,我有一个模块文件 modso.f 和一个“子例程文件”subso.f。

我还有一个静态链接对象(再次在 FORTRAN 中),假设 mya.a 带有 3 个子例程文件和 2 个模块文件,moda1.f 和 moda2.f。

在 myso.so 的链接中,我包含了 mya.a,当然还有 modso.o、subso.o。在 modso.f 和 subso.f 中,我有 USE 语句,用于使用 mya.a 中的 moda1.f 和 moda2.f 模块。

我的问题是:当我打开(在主程序运行时)myso.so 库(使用命令 dlopen(myso.so, RTLD_LAZY))时,我收到从 dlerror() 返回的错误: myso.so : undefined symbol: moda1_

所以换句话说,似乎.so库看不到.a库中的模块。在编译和链接阶段我没有收到任何错误/警告。

我在 Ubundu 下使用 pgi 10 fortran 90 编译器。上面的示例在 Windows 中运行良好(其中 .so 是 .dll,.a 是 .lib),

提前致谢。

Dear stackoverflow experts,

I want to create (with FORTRAN) a shared object file, lets say myso.so. In this .so I have one module file, modso.f, and one 'subroutine file', subso.f.

I also have a statically-linked object (in FORTRAN again), lets say mya.a with 3 subroutine files, and 2 module files, moda1.f and moda2.f.

At the linking of myso.so, I include the mya.a, and of course the modso.o, subso.o. In the modso.f and subso.f, I have the USE statement for using the moda1.f and moda2.f modules that are in mya.a.

What's my problem is: When I open (during runtime of main program) the myso.so library (using the command dlopen(myso.so, RTLD_LAZY)), I get this error returning from dlerror(): myso.so: undefined symbol: moda1_

So in other words, it seems that the .so library can't see the modules in the .a library. In compiling and linking phase I didn't get any errors/warnings.

I'm using pgi 10 fortran 90 compiler under Ubundu. The above example works fine in windows (where the .so are .dll and .a are .lib)

Thanks in advanced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽手叙旧 2024-12-31 18:44:46

这可能是因为链接顺序:

g++:静态库和动态库应按什么顺序链接?

链接阶段成功,因为加载动态库时解析符号,而不是链接。

It might be because of linking order:

g++: In what order should static and dynamic libraries be linked?

Linking phase is successfull because symbols are resolved when dynamic library is loaded, not linked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文