【发布时间】:2016-05-22 14:38:58
【问题描述】:
我在 Debian 机器上,我想为我的 Raspberry Pi 2 交叉编译一个项目。我已经设法使用 rustup 为一个简单的 hello world 完成了它,但不知道如何交叉编译 rust -openssl 板条箱。
我已经用 arm-linux-gnueabihf-gcc 编译了 openssl 并将其安装在我的home/opensslArm 目录中。
当我跑步时
OPENSSL_LIB_DIR=/home/johann/opensslArm/lib OPENSSL_INCLUDE_DIR=/home/johann/opensslArm/include cargo build --target=armv7-unknown-linux-gnueabihf
我得到这个错误:
failed to run custom build command for `openssl-sys-extras v0.7.11`
Process didn't exit successfully: `/home/johann/projects/test/target/debug/build/openssl-sys-extras-e1c84960cd35bc93/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("armv7-unknown-linux-gnueabihf")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
TARGET = Some("armv7-unknown-linux-gnueabihf")
debug=true opt-level=0
HOST = Some("x86_64-unknown-linux-gnu")
TARGET = Some("armv7-unknown-linux-gnueabihf")
TARGET = Some("armv7-unknown-linux-gnueabihf")
HOST = Some("x86_64-unknown-linux-gnu")
CC_armv7-unknown-linux-gnueabihf = None
CC_armv7_unknown_linux_gnueabihf = None
TARGET_CC = None
CC = None
HOST = Some("x86_64-unknown-linux-gnu")
TARGET = Some("armv7-unknown-linux-gnueabihf")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_armv7-unknown-linux-gnueabihf = None
CFLAGS_armv7_unknown_linux_gnueabihf = None
TARGET_CFLAGS = None
CFLAGS = None
running: "arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fPIC" "-march=armv7-a" "-o" "/home/johann/projects/test/target/armv7-unknown-linux-gnueabihf/debug/build/openssl-sys-extras-e1c84960cd35bc93/out/src/openssl_shim.o" "-c" "src/openssl_shim.c"
ExitStatus(ExitStatus(256))
command did not execute successfully, got: exit code: 1
--- stderr
In file included from src/openssl_shim.c:1:0:
/usr/include/openssl/hmac.h:61:34: fatal error: openssl/opensslconf.h: No such file or directory
compilation terminated.
thread '<main>' panicked at 'explicit panic', /home/johann/.cargo/registry/src/github.com-88ac128001ac3a9a/gcc-0.3.28/src/lib.rs:840
note: Run with `RUST_BACKTRACE=1` for a backtrace.
如果我导出有问题的变量,我会得到同样的错误。
我不知道我应该做什么,我不是交叉编译方面的专家。有没有人设法做到这一点?
编辑:我使用的是 rust-openssl 0.7.11。升级到 0.7.13 解决了这个问题(我现在可以看到 cargo 编译 rust-openssl 依赖项没有错误)但我现在有另一个问题:
error: linking with `arm-linux-gnueabihf-gcc` failed: exit code: 1
...
note: /usr/lib/gcc-cross/arm-linux-gnueabihf/5/../../../../arm-linux-gnueabihf/bin/ld: /home/johann/opensslArm/lib/libssl.a(s23_meth.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/johann/opensslArm/lib/libssl.a: error adding symbols: Bad value
如何添加-fPIC 标志?我应该用特定的标志重新编译 opensslArm 吗?
【问题讨论】:
-
在输出中有
/usr/include/openssl/hmac.h真的很可疑。这将是您通常安装的 OpenSSL 版本,而不是自定义版本。我想知道#include <foo>instead of#include "foo"是否会引起问题... -
感谢您的评论!我尝试克隆 rust-openssl 并手动编译 openssl-sys-extra ......它成功了!所以我做了一个
cargo update,rust-openssl 从 0.7.11 升级到 0.7.13,现在我有一个linking witharm-linux-gnueabihf-gcc` failed` 错误
标签: openssl raspberry-pi rust cross-compiling