[blfs-support] Using meson to build packages with libraries

Christopher Gregory christopher.gregory at mail.com
Thu Jun 28 02:13:18 PDT 2018

> Sent: Wednesday, June 27, 2018 at 9:24 PM
> From: "Christopher Gregory" <christopher.gregory at mail.com>
> To: blfs-support at lists.linuxfromscratch.org
> Subject: [blfs-support] Using meson to build packages with libraries
> Hello,
> I am surprised that no one has bothered to report this.  I have noticed that when meson and ninja are used to build a package, if that package has libraries to be installed, they get installed to /usr/lib64 unless you specifically add --libdir=/usr/lib to the meson configure line.
> This does affect packages already in the book.  All you need to do to confirm this is to do a dest-dir install and you will see the evidence for yourself.  I do not know if there is a global option somewhere in the main meson configuration that can be changed, but as a number of editors have fought to keep things out of /usr/lib64 then this spoils the work.  I only found this out by accident, when investigation why a package was not able to find the libraries of an installed package.  As soon as I added the --libdir=/usr/lib to the offending packages's meson configure line and recompiled and installed the error went away. 
> Regards,
> Christopher.
> -- 
> http://lists.linuxfromscratch.org/listinfo/blfs-support
> FAQ: http://www.linuxfromscratch.org/blfs/faq.html
> Unsubscribe: See the above information page

Well I have finally tracked down the exact trigger for this.  There are optional packages listed on ffmpeg page I believe that install libraries to /usr/lib64 unless forced to install to /usr/lib.  The first package in question is Jack audio.  Once this package was installed, unknown to me it created the /usr/lib64 directory.  What that then does is trigger an if statement in mesonbuild/mesonlib.py, namely, I believe:

if os.path.isdir('/usr/lib64') and not os.path.islink('/usr/lib64'):
        return 'lib64'

that will then cause subsequent packages that meson builds to put their libraries into /usr/lib64 instead of the desired /usr/lib.

The fix is two fold:

1) Put a comment in brackets next to the optional package to advise those installing that they need to change the location of the installed library to --libdir=/usr/lib.

2) Remove the lib64 directive from mesonlib.py by sed statements. 

There are at least three other optional packages that this would also need to be done for.  What this then achieves is consistency in the book with regards to warnings, and more importantly if someone does install a package that is not listed as optional in the book, and they did not notice that it created a /usr/lib64 directory that it would at least minimize the fall out from having a /usr/lib64 directory, whilst not actually fixing the wrong location itself.  Having the alert and fix for book optional packages gives people the heads up that there is still old but usable code out there that still does this practice.


More information about the blfs-support mailing list