如何使用命令行选项交叉编译scons附带的gpsd

问题描述 投票:1回答:2

我试图弄清楚如何在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

首先,我尝试使用命令行选项includedir和libdir指向目标文件,但scons仍然只使用主机ncurses库。但是在编译其他gpsd组件时,似乎scons正在使用正确的包含者。

    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包的解决方案,而不必更改构造文件。

cross-compiling scons buildroot gpsd
2个回答
0
投票

通过使用与LDFLAGS相同的设置设置环境变量LINKFLAGS,构建过程现在可以正常工作。

但我不明白为什么它通过设置includedir和libdir不起作用。


0
投票

在Buildroot中已有一个gpsd包,请参阅https://git.buildroot.org/buildroot/tree/package/gpsd/。你为什么要创造另一个?

© www.soinside.com 2019 - 2024. All rights reserved.