准备在rust中使用curl库
cargo add curl
编译的时候
Compiling openssl-sys v0.9.75
error: failed to run custom build command for `openssl-sys v0.9.75`
Caused by:
process didn't exit successfully: `/learning/rustproject/curlupload/target/debug/build/openssl-sys-88f374ddceb301fe/build-script-main` (exit status: 101)
需要静态编译openssl
下载openssl-1.1.1q
安装sudo apt-get install -y musl-dev musl-tools linux-headers-$(uname -r)
为了防止
出现
crypto/mem_sec.c:33:13: fatal error: linux/mman.h: No such file or directory
33 | # include
| ^~~~~~~~~~~~~~
compilation terminated.
建立软连接
sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm
sudo ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic
sudo ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
mkdir /learning/musl
CC="musl-gcc -fPIE -pie -static -idirafter /usr/include/ -idirafter /usr/include/x86_64-linux-gnu/" ./Configure no-shared no-async --prefix=/learning/musl --openssldir=/learning/musl/ssl linux-x86_64
make depend
make -j$(nproc)
在rust工程目录
export PKG_CONFIG_ALLOW_CROSS=1
export OPENSSL_STATIC=true
export OPENSSL_DIR=/learning/musl
cargo build
阅读(1457) | 评论(0) | 转发(0) |