1

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.

helios21
  • 135
  • 1
  • 9
  • I think you may need to show some (minimal, but complete) code. I don't understand why the symbol `moda1` would be referenced, since it is the name of a module, right? – eriktous Jan 06 '12 at 00:42
  • Yes, moda1 is the name of the module (and both the filename). OK, I will try to post some code, thanks for the answer. – helios21 Jan 06 '12 at 10:02

1 Answers1

1

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.

Community
  • 1
  • 1