How to Link Against STATIC libc on Ubuntu 13.10

How to Link Against STATIC libc on Ubuntu 13.10

 

I have been able to get digit for digit identical results on Ubuntu 13.10 x64 vs. Windows, if I compile my code like so:

ifort -zero -traceback -static-intel -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c SOURCEFILE.FOR

A colleague informed me that "-static-intel" does not mean I will get static c libraries linked into my program, so if I distribute the compiled .exe of my program, I may not get identical results on another Linux distribution.

My question is, is there any way to compile against the static version of libc (and any other required libraries?) to ensure that I get digit for digit agreement between different Linux platforms after I redistribute my .exe?

 

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You could include the full pathname of your libc.a in your link step, or use the big hammer: -static but if you have pre-conceived ideas of the consequences, you may be disappointed.

-static-intel does perform static linking of all eligible libraries provided with ifort, except MKL, including nearly everything of numerical importance.  The usual reason for choosing it is to avoid distributing shared objects so as to run on a platform without ifort installation.

If your application is unstable, your effort might be better spent finding and correcting lapses of correctness.

Are there any other flags that I'm missing?  My goal is exactly to be able to un-tar on a target machine and it just runs.  I'm developing on ubuntu-12.04.5-desktop-amd64.iso, and my test platform is RedHatEnterpriseServer 6.4.  Using the 32-bit platform, things work great.

I tried this:

source /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh ia32
ifort -zero -fno-omit-frame-pointer -traceback -static-intel -static-libgcc -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR

And it worked!  I tried "-traceback -static-intel -static-libstdc++" and it worked.  I tried "-static" and it worked.

But then I tried x64, and I've run into problems.  I tried all of these variations:

source /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh intel64

ifort -zero -traceback -static-intel -static-libgcc -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR

ifort -zero -traceback -static-intel -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR

ifort -zero -traceback -static -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR

And all of them produce this error:

./blah: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./blah)

 

What really puzzles me is that x86 version works, but the x64 version doesn't.  The target RHEL machine has libc.so.6 version 2.12 both for x64, and x86.  Are there any additional special flags that I need for the x64 version?  Or, what flags should I be using to get all the static libraries?

My goal is to develop on ubuntu-12.04.5-desktop-amd64.iso, and then deploy to RedHatEnterpriseServer 6.4, so that you can just un-tar the tarball, and it runs.  Apparently, RHEL has version 2.12 of  libc.so.6, both for x86, and x64.  I’ve had success with x86, but not so with x64.  I tried to compile like this:

source /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh ia32
ifort -zero -fno-omit-frame-pointer -traceback -static-intel -static-libgcc -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR
ifort -zero -fno-omit-frame-pointer -traceback -static-intel -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR
ifort -zero -fno-omit-frame-pointer -traceback -static -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR

And all of them ran just fine on RHEL.

But, for x64, none of them run!  I tried:

source /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh intel64
ifort -zero -traceback -static-intel -static-libgcc -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR
ifort -zero -traceback -static-intel -static-libstdc++  -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR
ifort -zero -traceback -static -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c BLAH.FOR

And all of them give me this error:

./blah: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./blah)

Am I missing something?  Why does it work on x86, but not on x64?

Not to belabor the obvious but, you’ve checked that there is a 64bit static version of libc on the development machine, right? I know Ubuntu tends to break some dev packages up, and you certainly can’t link against a static library that doesn’t exist.

-Zaak

It turns out I put the "-static" flag in the compiler arguments, but not in the linker arguments, and that's why it wasn't working.  Happy Friday everyone!

Leave a Comment

Please sign in to add a comment. Not a member? Join today