Rust 配方依赖于其他配方的库

问题描述

我正在尝试从 RaspBerry Pi 的 Bitbake 配方生成一个包:

inherit cargo

SUMMARY = "myapp"
DESCRIPTION = "Compile and configure myapp"
LICENSE = "CLOSED"
HOMEPAGE = "git://git.myserver.com:myapp/myapp.git"

DEPENDS = "openssl postgresql"

SRC_URI = "git://git.myserver.com/myapp/myapp.git;protocol=https;user=myuser:mypass;tag=v${PV}"
SRC_URI[sha256sum] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"

S = "${workdir}/git"

我正在编译的程序依赖于由 postgresql生成的 Postgresqllibpq。我的问题是链接器找不到 libpq,甚至在 DEPENDS 中。

输出错误为:

...
"-Wl,--end-group" "/home/yocto-image/build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/myapp/0.0.1-r0/recipe-sysroot-native/usr/lib/rustlib/x86_64-unkNown-linux-gnu/lib/libcompiler_builtins-e2523c360f03ba10.rlib" "-Wl,-Bdynamic" "-lpq" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
|   = note: /home/yocto-image/build/tmp/hosttools/ld: cannot find -lpq
|           collect2: error: ld returned 1 exit status
| 
| 
| error: aborting due to prevIoUs error
| 
...

解决方法

终于找到解决办法了。我正在 Ubuntu x86_64 PC 中交叉编译代码。该库是编译机器所必需的,而不是目标机器(Raspberry Pi)所必需的。解决方案只是安装 Ubuntu 中所需的库:

sudo apt-get install libpq-dev