【问题标题】:Meson cross compiling dependencies介子交叉编译依赖
【发布时间】:2018-02-08 16:29:41
【问题描述】:

您好,我正在尝试为 arm 交叉编译 systemd,但我卡在了 'mount' 交叉依赖上。

我设法从 util-linux 交叉编译 libmount,但无法弄清楚将它放在哪里或如何指定介子应该在哪里寻找它。

有一个 'mount-path' 选项,但即使提供它仍然显示:

Meson encountered an error in file meson.build, line 797, column 0:                                                    
Cross dependency 'mount' not found

我的交叉编译文件如下所示:

[binaries]                   
c = '/usr/bin/arm-linux-gnueabi-gcc'                       
cpp = '/usr/bin/arm-linux-gnueabi-g++'                     
ar = '/usr/arm-linux-gnueabi/bin/ar'                       
strip = '/usr/arm-linux-gnueabi/bin/strip'                 
pkgconfig = '/usr/bin/arm-linux-gnueabi-pkg-config'        

[host_machine]               
system = 'linux'             
cpu_family = 'arm'           
cpu = 'cortex-m4'            
endian = 'little'            

[build_machine]              
system = 'linux'             
cpu_family = 'x86_64'        
cpu = 'i686'                 
endian = 'little' 

顺便说一句,如果您知道另一种在没有这种荒谬(恕我直言)设置的情况下在 arm 上安装 systemd 的方法,那就太好了。

谢谢。

【问题讨论】:

  • apt-get install libmount-dev曾在ubuntu11.10工作

标签: cross-compiling mount meson-build


【解决方案1】:

Meson 使用 pkg-config 工具来查找依赖项。该工具使用 PKG_CONFIG_PATH 环境变量搜索所谓的包配置文件。 您可以检查以下是否有 mount

$ pkg-config --list-all

这自然是因为你刚刚编译了但是没有提供包配置文件mount.pc可以找到。检查 libmount 源,它应该包含安装过程使用的 mount.pc.in。在交叉编译的情况下,需要根据guide手动转成mount.pc。

创建包配置文件后应该可以成功运行了:

$ pkg-config --validate mount

您还可以检查变量的有效性:

$ pkg-config --cflags mount
-I/home/<>/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/libmount -I/home/<>/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/blkid -I/home/<>/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/uuid

$ pkg-config --libs mount  
-lmount

顺便说一句,这是我得到的 mount.pc 的内容:

prefix=/usr
exec_prefix=/usr
libdir=/usr/lib
includedir=/usr/include

Name: mount
Description: mount library
Version: 2.29.1
Requires.private: blkid
Cflags: -I${includedir}/libmount
Libs: -L${libdir} -lmount

顺便说一句,如果你知道另一种在没有这个的情况下在 arm 上安装 systemd 的方法 荒谬(恕我直言)设置它会很好。

systemd 切换到介子,所以现在只能这样了,除非你想用 autotools 构建旧版本。

但从更广泛的角度考虑,您还可以查看yocto,它专注于简化获取交叉编译的 linux 发行版。


更新

正如@Yasushi Shoji 正确指出的那样,对于交叉编译情况,应该使用 PKG_CONFIG_LIBDIR,因为它可以防止不希望/错误地使用本地系统包,请检查this。 p>

【讨论】:

  • 请注意,“pkg-config另外查看PKG_CONFIG_PATH指定的[...]目录”。这意味着“将始终搜索默认目录”,并且它可能会找到 .pc 文件的本机版本。 IMO,最好改用PKG_CONFIG_LIBDIR。有关详细信息,请参阅pkg-config(1)
  • 嘿,这很方便。谢谢。现在我在同一行收到“无法为 mount 生成 cargs:”错误。但我猜这是另一个故事了。
  • 我只是想添加 libmount 是utils-linux的一部分
  • @badri 那么奇怪的是你有“错误:交叉文件中的错误值......”但我注意到另一件事。通常 .pc 文件应该在 .../pkgconfig 目录中,但这不是强制性的,重要的是 .pc 文件必须在 PKG_CONFIG_LIBDIR 指向的目录中,即在您的情况下 PKG_CONFIG_LIBDIR 应该包含 /home/badri/ arm_libs/meson_trial/lib/mountpc 或 .pc 文件需要上移一个目录
  • @badri 那么你应该有 $ export PKG_CONFIG_LIBDIR=/home/badri/arm_libs/meson_trial/pkgconfig (之前你提到了另一个目录),你不需要其他任何东西,不要把 pkg_config_libdir 交叉文件(这是它的无效关键字)并且不要在 cmd 行中使用 --libdir 。只需设置环境。变量,你需要重新设置你的构建目录,如果你删除它然后用 $ meson --cross-file cross_file.txt builddir --prefix=/home/badri/arm_libs/meson_trial 再次设置会更容易
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-17
  • 1970-01-01
  • 2012-08-01
  • 1970-01-01
  • 2021-09-28
相关资源
最近更新 更多