Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top