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




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
http://www.ornl.gov/fed/Theory/stci/stellarator_theory.html


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

---------------------------------------------------------
Drew McCormack

www.macanics.net


_______________________________________________ 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
References: 
 >Re: Linking f90 modules in static libraries with ifort (From: Don Spong <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.