- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am having a hard time understanding the following:
galerkin:~/Development/ifort-Linking bourdin$ ifort -V
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20070112 Package ID: m_fc_c_9.1.036
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
I have 3 .a libraries compiled separatly with icc/ifort:
galerkin:~/Development/ifort-Linking bourdin$ file *a
libexoIIv2c.a: current ar archive random library
libexoIIv2for.a: current ar archive random library
libnetcdf.a: current ar archive random library
the following link command works fine:
ifort -o testcp testcp.o libexoIIv2for.a libexoIIv2c.a libnetcdf.a
This one doesn't (I get tons of ld: Undefined symbols: problems)
ifort -o testcp testcp.o libexoIIv2c.a libexoIIv2for.a libnetcdf.a
This works:
ifort -o testcp testcp.o -L. -lexoIIv2for -lexoIIv2c -lnetcdf
But this doesn't (also complaining about missing symbols):
ifort -o testcp testcp.o -L. -lexoIIv2c -lexoIIv2for -lnetcdf
Is this normal? If so, how am I supposed to figure out the order in which to list the .a ?
Thanks,
Blaise
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not knowing what's in those libraries, I'll make the general comment that most linkers process libraries in a left to right order. Once it determines that no additional symbols can be resolved from the current libray, it moves on to the next and does not revisit the first one.
So lets say that you have lib1.a with routines A and B, where A calls C. lib2.a contains routine C which calls B. A main program calls A. ou link like this:
ifort main.f90 lib1.a lib2.a
The main program object is seen with a call to A. Next, lib1 is opened, it resolves the call to A and there's an unresolved reference to C. Since B is not referenced yet, it is not pulled in. Then lib1.a is closed and lib2.a is opened. It resolves C but now there's an unresolved reference to B.
The way you'd have to work this is to name libraries twice, or sometimes even more. For example:
ifort main.f90 lib1.a lib2.a lib1.a
Does this help?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page