wahorger,
I suspect that linking against libraries built with/mklib will prevent a routine declared as external but never called from being 'loaded' into the executable. Please look at the souces main.for
integer*4 x,y,z
external mult
x=2
y=3
write(*,*) 'x=',x,' y=',y
call sum(x,y,z)
write(*,*) 'sum: z=',z
end
and libsrc.for
subroutine sum(a,b,c)
integer*4 a,b,c
c=a+b
end
subroutine mult(a,b,c)
integer*4 a,b,c
c=a*b
end
. Using script build.bat
@echo off
setlocal
SET DEBUG_OPT=/debug
ftn95 %DEBUG_OPT% libsrc.for
slink libsrc1.lnk
ftn95 %DEBUG_OPT% libsrc.for /mklib
ftn95 %DEBUG_OPT% main.for
slink main.lnk
slink main1.lnk
endlocal
archive libsrc.lib is built with /mklib, archive libsrc1.lib is built without /mklib, main.exe is linked against libsrc.lib, main1.exe is linked against libsrc1.lib. Looking into both executables via a hex editor you see that mult is not contained in main.exe, but in main1.exe. You might also want to use commands
dumpbin main.exe /all
dumpbin main1.exe /all
and see that string
SECT1 notype () External | _MULT
does not occur in the output of the first dumpbin command, but in that of the second.
The lnk files used are main.lnk
lo main
lo libsrc.lib
file main.exe
, main1.lnk
lo main
lo libsrc1.lib
file main1.exe
and libsrc1.lnk
archive libsrc1.lib
addobj libsrc.obj
file
Regards
Dietmar