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

Trying to build a shared library with -i-static

Intel_C_Intel
Employee
639 Views
I'm using the latest intel 9.1 fortran and c compilers to build a .so library for use with the Fieldview program. I would like to have the intel libraries built into my shared library, so I don't have to LD_LIBRARY_PATH to the libs. I compile each C or Fortran routine with -fPIC, then create the shared library with the command :

ifort -shared -i-static *.o -o fv_toolkit.so

I get the error :

ld: /fltapps/boeing/intel/compiler91/fce/9.1.036/lib/libifcore.a(for_close.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/fltapps/boeing/intel/compiler91/fce/9.1.036/lib/libifcore.a: could not read symbols: Bad value

If I remove the -i-static option, then it links fine. Any help that can be provided would be appreciated.

Bernie Borenstein
The Boeing Company
0 Kudos
3 Replies
Lorri_M_Intel
Employee
639 Views

We do provide Fortran runtime libraries built "position-independent" on the Intel Fortran kit. We started that very recently, at the request of one customer who was experimenting with them. To find out if your kit is new enough to have them, check the library area of the installed compiler for files *_pic.a. This directory will be something like:

/opt/intel/fc/9.1.xxx/lib

where "xxx" is your version number.

That said, because it's rather experimental, there are nocommand line switches [yet?] to automaticallylink against them.

If you're feeling adventurous, you can do as we advised the original requestor: manually link against the "pic" Intel Fortran libraries.

First - add the "-dryrun" switch to whatever command you are using to link the executable. This will show you the calls that the driver would have made, if it were to actually do the link. Let me recommend that you output that to a file, and maybe edit that file to createa script you can invoke.

Once you have the script - modify -lifcore to -lifcore_pic

I can't, of course,promise that we're going to make this easier, but I *do* understand it's quite awkward.

- Lorri

0 Kudos
Neon_Ngo
Beginner
639 Views
Is the -i-static and -fPIC together still experimental in the 10.x or 11.x versions of ifort? Is there an ISSUE # for this?

Quoting - lorri_menard

We do provide Fortran runtime libraries built "position-independent" on the Intel Fortran kit. We started that very recently, at the request of one customer who was experimenting with them. To find out if your kit is new enough to have them, check the library area of the installed compiler for files *_pic.a. This directory will be something like:

/opt/intel/fc/9.1.xxx/lib

where "xxx" is your version number.

That said, because it's rather experimental, there are nocommand line switches [yet?] to automaticallylink against them.

If you're feeling adventurous, you can do as we advised the original requestor: manually link against the "pic" Intel Fortran libraries.

First - add the "-dryrun" switch to whatever command you are using to link the executable. This will show you the calls that the driver would have made, if it were to actually do the link. Let me recommend that you output that to a file, and maybe edit that file to createa script you can invoke.

Once you have the script - modify -lifcore to -lifcore_pic

I can't, of course,promise that we're going to make this easier, but I *do* understand it's quite awkward.

- Lorri


0 Kudos
Kevin_D_Intel
Employee
639 Views
Quoting - Neon Ngo
Is the -i-static and -fPIC together still experimental in the 10.x or 11.x versions of ifort? Is there an ISSUE # for this?


Yes, still experimential. It hasnot been "officially" released although the same *_pic.a libraries mentioned are provided even in the latest 11.1 release.

I noted the current internal tracking id below.

(Internal tracking id : DPD200026104)

(Resolution Update on 09/30/2011): This defect is fixed in the Intel® Fortran Compiler 2011 release

0 Kudos
Reply