So maybe this is me exposing my naivety in terms of linking and compiling.
I'm trying to compile some Fortran code such that it can run as a stand alone binary. One issue (among several) is that I want to compile on a system with GLIBC 2.14 but run on one with 2.11. Is it possible to statically link in libraries like GLIBC, or is that impossible because of the library's size?
My Makefile uses -static, -static-libgcc, and -static-libgfortran flags and the following compiler flags
-c -cpp -fall-intrinsics -ffpe-trap=invalid,zero -std=f2003
However, when I use ldd on the output, I get
linux-vdso.so.1 => (0x00007fff13b63000)
libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00007febfd7cf000)
libm.so.6 => /lib64/libm.so.6 (0x00007febfd578000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007febfd362000)
libquadmath.so.0 => /usr/lib64/libquadmath.so.0 (0x00007febfd12c000)
libc.so.6 => /lib64/libc.so.6 (0x00007febfcd9c000)
/lib64/ld-linux-x86-64.so.2 (0x00007febfdae7000)
Update
The machine I'm compiling on is running openSUSE 12.2:
Linux 3.4.33-2.24-desktop #1 SMP PREEMPT x86_64 x86_64 x86_64 GNU/Linux
While the machine I'm trying to execute on is openSUSE 11.4:
Linux 2.6.37.6-24-desktop #1 SMP PREEMPT x86_64 x86_64 x86_64 GNU/Linux
Update 2
I've re-written the makefile, and I'm trying to compile with ifort (the intel compiler) because it provides the static-intel flag which reduces some of the dependencies.
My ldd output is now
linux-vdso.so.1 => (0x00007fff381ff000)
libm.so.6 => /lib64/libm.so.6 (0x00007f89b07cf000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f89b05b2000)
libc.so.6 => /lib64/libc.so.6 (0x00007f89b0222000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f89b001e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f89b0a26000)
Using the following compiler flags
FCFLAGS = -cpp -static-intel -static-libgcc
The problem is if I do just -static (or -static-intel -static) then I get
ld: cannot find -lm
ld: cannot find -lpthread
ld: cannot find -lc
ld: cannot find -ldl
ld: cannot find -lc
make: *** [IDP] Error 1
Which I believe is because I don't have static versions of these libraries on my system
UPDATE 3
I also tried the approach of providing the shared objects in a library (as suggested by [this post])(https://stackoverflow.com/a/3214232/615257) but it just segmentation faults.
This is a common problem. All the later distributions from 2011 onwards do not have static versions of the 64-bit libraries. They ship with the 32-bit versions but not with 64. You just have to use the shared lib versions of libm, libc etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With