cross-compiling - 如何仅使用命令行选项交叉编译 scons 附带的 gpsd
问题描述
我试图弄清楚如何在 buildroot 环境中将 GPSD 3.16 交叉编译为外部包。我已经能够告诉 scons 它应该使用哪个编译器并生成正确的编译文件。
scons target=arm-buildroot-linux-gnueabihf-gcc
file gpsd
gpsd: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 4.9.0, not stripped
所以它通常可以工作,但是当 scons 尝试将 cgps 与 ncurses 链接时,构建会失败。当然 scons 会产生错误,因为它试图链接到 buildroot 主机 ncurses 库。
arm-buildroot-linux-gnueabihf-gcc -o cgps -pthread -Wl,-rpath,/buildroot/host/usr/lib -Wl,-rpath,/buildroot/host/lib cgps.o -L. -L/buildroot/host/usr/lib -lgps_static -lm -lrt -lncurses /buildroot/host/usr/lib/libncurses.so: file not recognized: File format not recognized
首先,我尝试使用命令行选项 includeir 和 libdir,它们指向目标文件,但 scons 仍然只使用主机 ncurses 库。但似乎 scons 在编译其他 gpsd 组件时使用了正确的 includedir。
arm-buildroot-linux-gnueabihf-gcc -o lcdgps.o -c -Wmissing-prototypes -Wextra -Wall -Wno-uninitialized -Wno-missing-field-initializers -Wcast-align -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wreturn-type -pthread -Wmissing-declarations -O2 -pthread "-I/target/usr/local/include -I/target/usr/local/include/ncurses"
我也尝试使用 pkgconfig 命令行选项,但得到了相同的结果。
到目前为止,我无法让 scons 使用目标 ncurses 库而不是主机库。在此项目中无法使用 GPSD 作为内部 buildroot 包,因此我正在寻找基于外部 GPSD 包的解决方案,而无需更改构造文件。
解决方案
通过使用与 LDFLAGS 相同的设置设置环境变量 LINKFLAGS,构建过程现在可以正常工作。
但是我不明白为什么通过设置includedir和libdir它不起作用。
推荐阅读
- ios - 在 Swift 中以编程方式将 UIImageView 替换为 PDFView
- rxjs - fromEvent 函数中的过滤器运算符在 RxJS6 中不起作用
- java - 使用对象列表构建树
- asp.net-core - AspNet Core 2.0 Windows 服务和唯一的 ASPNETCORE_ENVIRONMENT 变量
- c++ - EXPECT_CALL 用于具有 unique_ptr 引用类型参数的模拟函数
- performance - 与 foldr 相比,模式匹配的性能更好
- codenameone - Codename One TextArea Padding 无效
- android - 按钮上的 setPadding() 以编程方式不起作用
- python - 存储利率和复利计算总和的数据类型是什么?
- python - 日元的算法实现不选择最短路径