Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: static compilation

45 views
Skip to first unread message

Thomas Jahns

unread,
May 22, 2013, 11:20:13 AM5/22/13
to
On 05/22/2013 12:39 PM, Rudra Banerjee wrote:
> This is possibly more a linux(or even fedora) question, then fortran.
> In my code, while compiling I get error as:
> $ gfortran -static prime.f90
> /usr/bin/ld: cannot find -lgfortran
> /usr/bin/ld: cannot find -lm
> /usr/bin/ld: cannot find -lquadmath
> /usr/bin/ld: cannot find -lm
> /usr/bin/ld: cannot find -lc
> collect2: error: ld returned 1 exit status
>
> So, I need static libraries. Any help for fedora user?

Not really, linking with a static libc is no longer supported on Linux because
of the way nsswitch works, i.e. the resulting binary might work but is no more
portable to other systems (depends on the systems nsswitch configuration) than a
dynamically linked binary.

Since this problem does not apply to libgfortran, libm and libquadmath you might
get better results, once you have installed the corresponding .a files, by
trying something like:

$ gfortran prime.f90 -Wl,-Bstatic -lgfortran -lm -lquadmath -Wl,-Bdynamic

Regards, Thomas

Rudra Banerjee

unread,
May 23, 2013, 5:17:53 AM5/23/13
to
Thanks,
But I am not looking for portability.
This is the problem I faced when I tried to compile a code with ifort
with "-fast" option enabled.
"It sets the following options:

· On OS X* systems: -ipo, -mdynamic-no-pic, -O3,
-no-prec-div, and -xHost On Windows* systems: /O3, /Qipo, /Qprec-div-,
and /QxHost
On Linux* systems: -ipo, -O3, -no-prec-div, -static, and
-xHost""
from man ifort
0 new messages