Hi,
I've been looking for the answer to this in the manuals. I have a
mixed Fortran/C DSO that I'm trying to delay_load. It needs to read
from a COMMON block that is initialized in the main program; however,
it is getting values of 0 for all the COMMON data. When I don't
delay_load it, it's fine.
The problem is exhibited by the following small pure Fortran example. I
show main.f (a main program), bar.f (which will become the dso) and a
Makefile that makes four targets:
nolib: just links main.o and bar.o
lib: links main.o and libbar.a (an archive)
dso: links main.o and libbar.so (a dso)
delay: links main with -delay_load libbar.so
All except delay print "int = 3", as expected. delay prints "int = 0".
Any thoughts?
Thanks.
main.f:
PROGRAM foo
IMPLICIT NONE
COMMON/foobar/int
INTEGER int
int = 3
CALL bar
END
bar.f:
SUBROUTINE BAR
IMPLICIT NONE
INTEGER int
COMMON/foobar/int
WRITE( 6, '(A,I3)' )'int =', int
END
Makefile:
FFLAGS = -g -freeform -n32
all: nolib lib dso delay
main.o: main.f
f90 -c $(FFLAGS) main.f
bar.o: bar.f
f90 -c $(FFLAGS) bar.f
libbar.a: bar.o
ar -rs libbar.a bar.o
libbar.so: libbar.a
-rm so_locations
ld -shared -all libbar.a -o libbar.so
nolib: main.o bar.o
f90 -o nolib $(FFLAGS) main.o bar.o
lib: main.o libbar.a
f90 -o lib $(FFLAGS) main.o libbar.a
dso: main.o libbar.so
f90 -o dso $(FFLAGS) main.o libbar.so
delay: main.o libbar.so
f90 -o delay $(FFLAGS) main.o -delay_load libbar.so