How to create a dynamic c library in Rust that is statically linked to glibc

Viewed 292

I am working on an Apache2 web server module written in Rust.

I have managed to compile the and get a .so file but when I move the library to another docker image and try to include it in the httpd.conf file I get the following error:

httpd: Syntax error on line 190 of /etc/httpd/conf/httpd.conf: Cannot load modules/libmod_hello.so into server: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /etc/httpd/modules/libmod_hello.so)

I probably should be able to make this work on that server by compiling the code against version 2.18 of GLIBC but doing that I will have to compile the code against all available GLIBC versions out there and that is obviously not practical.

Is there any way I can statically link my library to glibc so that I can deploy the library on different apache servers?

I added the following lines to config.toml

[build]
rustflags = ["-C", "target-feature=+crt-static"]
target = "x86_64-unknown-linux-gnu"

but now I get the following error:

error: cannot produce dylib for `mod_hello v0.0.2 (/src/examples/mod_hello)` as the target `x86_64-unknown-linux-gnu` does not support these crate types
0 Answers
Related