Xref: utzoo comp.lang.fortran:3965 comp.sys.sgi:6379 Path: utzoo!attcan!uunet!cs.dal.ca!silvert From: silvert@cs.dal.ca (Bill Silvert) Newsgroups: comp.lang.fortran,comp.sys.sgi Subject: Re: archiving block data subroutines... Summary: linkers are too damn smart Message-ID: <1990Oct22.130143.29775@cs.dal.ca> Date: 22 Oct 90 13:01:43 GMT References: <1990Oct22.033107.5159@ux1.cso.uiuc.edu> Sender: silvert@cs.dal.ca.UUCP (Bill Silvert) Reply-To: bill%biomel@cs.dal.ca Distribution: comp Organization: Habitat Ecology Div., Bedford Inst. of Oceanography Lines: 19 In article <1990Oct22.033107.5159@ux1.cso.uiuc.edu> jeffb@aquifer.las.uiuc.edu (Jeffrey Biesiadecki) writes: >We have a library written in Fortran77 which includes a block data >subroutine. If we use "ar" to archive the object files of the library, >and then try to compile a program using the resulting "lib???.a" file, >everything works fine EXCEPT the block data subroutine is never executed >(that is, the initializations are not made). If the block data object file >is linked in explicitly with the fortran compiler, then the initializations >are done. This is a common (:)) problem which arises from the fact that the linker looks only for subroutines that are called, and since block data is not called, it doesn't get linked. One sure fix is to combine the block data unit with a subroutine in one file, since the entire file with both units will then get loaded if the subroutine is called. -- William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2. Tel. (902)426-1577 UUCP=..!{uunet|watmath}!dalcs!biomel!bill BITNET=bill%biomel%dalcs@dalac InterNet=bill%biomel@cs.dal.ca