Trouble creating statically linked executable
Mikael Morin
mikael.morin@sfr.fr
Sat Feb 1 22:14:00 GMT 2014
Le 01/02/2014 21:21, ken72cc a écrit :
> I'm trying to create a standalone executable that will run on a system w/o
> fortran installed. Spent the entire morning and cannot figure out how to do
> it. If I try the following, I get the familiar error message that the
> lapack library can't be found even though the static libraries exist in the
> specified directory:
>
>> [guest@T61 DGELS_Lib]$ gfortran -o dgels3 TestDGELS_2.f -static
>> -Wl,-R/usr/lib64/atlas-sse3 -llapack -lf77blas
>> /usr/bin/ld: cannot find -llapack
>> collect2: ld returned 1 exit status
>>
>> [guest@T61 DGELS_Lib]$ ls -l /usr/lib64/atlas-sse3/liblapack.a
>> /usr/lib64/atlas-sse3/libf77blas.a
>> -rw-r--r--. 1 root root 562242 Mar 20 2012
>> /usr/lib64/atlas-sse3/libf77blas.a
>> -rw-r--r--. 1 root root 9639442 Mar 20 2012
>> /usr/lib64/atlas-sse3/liblapack.a
>
> If I don't use the library path option and provide full path names to the
> libraries I still get an error:
>
>> [guest@T61 DGELS_Lib]$ gfortran -o dgels3 -static TestDGELS_2.f
>> /usr/lib64/atlas-sse3/liblapack.a /usr/lib64/atlas-sse3/libf77blas.a
>> /usr/bin/ld: cannot find -lm
>> collect2: ld returned 1 exit status
>
> What am I doing wrong?
>
For the last problem I guess it doesn't find libm.a.
If you want to play fancy tricks with the linker, you'll be probably
better off calling it directly instead of through gfortran. As a
starting point, you can use gfortran -v to know what arguments are
passed to ld. Then read the docs. ;-)
Mikael
More information about the Fortran
mailing list