-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link libgfortran statically when features=static
#88
Comments
This is possible if
On some Linux distribution, including ArchLinux which I usually use,
Basically, it is not possible to link share library in static manner. |
Strange enough,I have both static and dynamic libraries installed on my system. However rustc link dynamically gfortran and quadmath. is there a way to ask rustc link statically? i understand by default dynamic is better. but for portability of binaries,static is more convenient. thanks, Jianshu |
This behavior should be fixed. I'll look into it. |
features=static
It seems this question is related to gcc/gfotran (due to libquadmath not linked statically): https://stackoverflow.com/questions/17910684/static-libgfortran-in-library-build . It is the same on linux for me. On ubuntu like system, libgfortran.a and libquadmath.a are all installed after installing gcc/gfortran, they are just forced to link dynamically. I have been struggling with this problem for several weeks. Thanks, Jianshu |
Hello! Is there any solution to it? It really confuse me for times. Thanks @jianshu93 @termoshtt |
I think still no. linux force dynamic link for library quadmath while gfortran relies on it. therefore libfortran.so will be used instead of .a |
I found a temporary solution. rustc can link However, the path of libgfortran.a can be get by |
but quadmath is still linked dynamically right. but still this is much better than before, at least gfortran is static now. Thanks Jianshu |
and you can use the same way to the quadmath, it works
…---- Replied Message ----
| From | ***@***.***> |
| Date | 03/16/2023 02:45 |
| To | ***@***.***> |
| Cc | ***@***.***>***@***.***> |
| Subject | Re: [blas-lapack-rs/openblas-src] Link libgfortran statically when `features=static` (Issue #88) |
but quadmath is still linked dynamically right. but still this is much better than before, at least gfortran is static now.
Thanks
Jianshu
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
is there a easy way to add those to a configure file so that I do not need to worry about them next time? Thanks Jianshu |
I have no idea. I use Then, I use the following content in println!("cargo:rustc-link-lib=static=gfortran");
println!("cargo:rustc-link-search=path/to/your/libgfortran.a");
if cfg!(target_arch="x86_64") {
println!("cargo:rustc-link-lib=static=quadmath");
println!("cargo:rustc-link-search=path/to/your/libquadmath.a");
} Maybe this method can be done in |
This does not work for me. Is that because I have both dynamic and static installed? Thanks, |
I tried this method on Ubuntu22, which has both dynamic and static library, and it works. I dont know why it doesn't work for you. I'm sorry that I can't help you. |
It turns out that I am on a linux server, which is annoying for building/linking/installing libraries. I use your strategy and it compiles but the last step it complained that native static libgortran.a was not found despite I provide the search path for libgfortran.a as you did. I will test on a regular Linux system and get back. Thanks, Jianshu |
Hello Team,
With openblas static feature, it can be linked statically but the gfortran itself was linked dynamically (gcc -lgfortran was required to link openblas), e.g, libgfortran.so.5 was actually linked to the binary if using ldd binary, together with libquadmath.so.0. I am wondering whether gfortran can be linked statically by gcc.
Thanks,
Jianshu
The text was updated successfully, but these errors were encountered: