Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Linking f90 modules in static libraries with ifort
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linking f90 modules in static libraries with ifort


Thanks. Running ranlib -c on the library file before linking has also solved the problems I was having.


On May 24, 2006, at 1:56 AM, Drew McCormack wrote:

On 12/05/2006, at 10:58 PM, Don Spong wrote:

I've also had problems with linking in variables through f90 modules in a larger code I've been trying to port to ifort on my MacBook Pro. I reported this to Intel Premier Support in late April and am still pursuing it with them. In this case I'm using both the -I<dirname> switch for the *.mod files (which reside in a separate directory) and linking in a library containing the associated *.o files. With smaller test codes I've had some success by playing around with the order that I list things on the load line. E.g.,

ifort -o xrun main.o -Imodpath lib1.a lib2.a                     seemed to work for at least one of my codes.

Don. Spong

Intel and Apple have solved this problem for me, and I am posting the solution in case it helps someone.
Turns out there is no bug in ifort or ld. You simply need to use the -c option with ranlib:

ifort -c something.f
ar -r libblah.a something.o
ranlib -c libblah.a
ifort main.f libblah.a

From Apple's man page for ranlib:

       -c     Include  common symbols as definitions with respect to the table
              of contents.  This is seldom the intended behavior  for  linking
              from  a  library,  as  it forces the linking of a library member
              just because it uses an uninitialized global that  is  undefined
              at  that  point  in  the  linking.  This option is included only
              because this was the original behavior of ranlib.   This  option
              is not the default.

Hope this helps someone.


Drew McCormack


Donald A. Spong, Fusion Energy Theory, ORNL

One Bethel Valley Road, Bldg. 5700

P. O. Box 2008, Room R-F312

Oak Ridge, Tennessee  37831-6169

Phone: (865) 574-1304   FAX: (865) 576-7926                   E-mail: email@hidden

web page:


Do not post admin requests to the list. They will be ignored.
Fortran-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 >Re: Linking f90 modules in static libraries with ifort (From: Don Spong <email@hidden>)
 >Re: Linking f90 modules in static libraries with ifort (From: Drew McCormack <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.