2

Hello I am trying to cross compile systemd for arm, but I got stuck on 'mount' cross depencency.

I managed to cross compile libmount from util-linux but can not figure out where to put it or how to specify where should meson look for it.

There is a 'mount-path' option, but even when providing it it still says:

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

My cross compile file looks like this:

[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' 

Btw if you know about another way to get systemd on arm without this ridiculous(IMHO) setup it would be nice.

Thank you.

1
  • apt-get install libmount-dev worked for in ubuntu11.10
    – Princekin
    Sep 8, 2021 at 6:18

1 Answer 1

3

Meson uses pkg-config tool to find dependencies. This tool searches, so called, package config files using PKG_CONFIG_PATH environment variable. You can check that there is no mount in:

$ pkg-config --list-all

This is naturally because you've just compiled but did not provide package config file mount.pc to be found. Check libmount sources, it should contain mount.pc.in that is used by installation process. In cross-compiling case, it should be turned into mount.pc manually according to guide.

After creating package config file you should be able to successfully run:

$ pkg-config --validate mount

You can also check validness of variables:

$ 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

BTW, this is the contents of mount.pc that I've got:

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

Btw if you know about another way to get systemd on arm without this ridiculous(IMHO) setup it would be nice.

systemd switched to meson, so now it's only the way, unless you want to build older version with autotools.

But thinking wider, you can also take a look at yocto which focuses on simplifying getting cross-compiled linux distributions.


Update

As, @Yasushi Shoji correctly pointed out, for cross-compilation case, PKG_CONFIG_LIBDIR should be used instead, as it prevents undesired/wrong usage of local system packages, check this.

16
  • 2
    Note that "pkg-config will additionally look in the [...] directories specified by the PKG_CONFIG_PATH". This means that "The default directory will always be searched", and it might find native version of .pc files. It'd be better, IMO, to use PKG_CONFIG_LIBDIR instead. See pkg-config(1) for more details. Feb 10, 2018 at 6:21
  • Hey, that's pretty handy. Thanks. Now I get "Could not generate cargs for mount:" error on the same line. But that's a story for another time I guess.
    – Dalbenn
    Feb 12, 2018 at 9:14
  • 2
    I just wanted to add the libmount is part of utils-linux
    – ChrisG
    Apr 18, 2019 at 13:39
  • 1
    @badri then it's strange that you have "ERROR: Malformed value in cross file ... " but I noticed another thing. Typically .pc file should be in .../pkgconfig directory but that is not mandatory, the important thing that .pc files must be in directory(ies) that pointed by PKG_CONFIG_LIBDIR, i.e. in your case PKG_CONFIG_LIBDIR should contain /home/badri/arm_libs/meson_trial/lib/mountpc or .pc files needs to be move one directory up
    – pmod
    May 4, 2020 at 10:11
  • 1
    @badri then you should have $ export PKG_CONFIG_LIBDIR=/home/badri/arm_libs/meson_trial/pkgconfig (previously you mentioned another dir), you don't need anything else , do not put pkg_config_libdir to cross file (that's invalid keyword for it) and don't use --libdir in cmd line. Just set env. variable and you need to re-setup your build dir, easier if you remove it and then setup again with $ meson --cross-file cross_file.txt builddir --prefix=/home/badri/arm_libs/meson_trial
    – pmod
    May 4, 2020 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.