Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

sequence dependences of static libs on ifort command line?

woshiwuxin
Novice
504 Views

Hi, everyone!

Suppose we have three different static libs, namely one.a, two.a, three.a.

If the executable is linked as the command below:

[bash]ifort -o main one.a two.a three.a[/bash]

It may not work. However, if I change the sequence of the statlic libraries on the command line, e.g.

[bash]ifort -o main three.a one.a two.a[/bash]

It would work.

So, here is my question. Is there a sequence dependence of static libs on ifort command line?

0 Kudos
1 Solution
Steven_L_Intel1
Employee
504 Views
The list of libraries you specify is just passed to ld as-is. ld may not go back to an earlier library if a later one adds a reference to a routine in an earlier library. You may want to add the set of libraries twice to the command line.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
505 Views
The list of libraries you specify is just passed to ld as-is. ld may not go back to an earlier library if a later one adds a reference to a routine in an earlier library. You may want to add the set of libraries twice to the command line.
0 Kudos
TimP
Honored Contributor III
504 Views

For recent versions of gnu ld, you may pass the group directives from the compiler, e.g.

-Wl,--start-group *.a -Wl,--end-group

so as to request re-scanning for circular dependencies among those .a files.

The MKL documentation includes examples of this.

0 Kudos
Reply