Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.


  Search this Thread
Old 05-29-2019, 03:15 PM   #1
Registered: Apr 2015
Posts: 103

Rep: Reputation: Disabled
Cross Compiling with Meson

I need the 32-bit version of GLIB. With the tool chain build from LFS-multilib, the meson build fails. I have built other 32-bit packages with meson. So, this
one must have some build scripts which elude me. At the bottom of my post you'll find my configure line and my cross-file definitions for feeding to meson
during configure.

The crux of the matter is that indeed the compiler commands get executed correctly, e.g., with the -m32 gcc command switch but the link fails.
gcc -o glib/ << numerous object files >> \
-Wl,--no-undefined -Wl,--as-needed -shared -fPIC -Wl,--start-group -Wl,-soname,\
-Wl,-z,nodelete -Wl,-Bsymbolic-functions /usr/lib32/ -Wl,--end-group -pthread
/usr/bin/ld: /usr/lib32/ error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
A couple of things. I don't know why meson configured to try and link in a shared file. 'libpcre.a' exists in /usr/lib32. links to, which is type
ELF 32-bit LSB shared object, Intel 80386. Meson, actually just writes out a file of commands in compile_commands.json. Ninja prints them as well. I replaced
from the command above with libpcre.a. I got back : Architecture of i386 input file is incompatible with i386:x86-64. So, the linker thinks I want to link a 64-bit library but
the *.o files are all the wrong type. The fix was to use the LD flag "-m elf_i386".
I put that in the cross-file definitions file but configure failed. Specifically, it's the line c_link_args = [-m elf_i386]. Prepending LDFLAGS="-m elf_i386" didn't work either. I'm
missing something. But this is a new build system that we'll have to deal with.
My configure line, edited for readability.
CC="gcc -m32" CXX="g++ -m32" \
meson \
-Dhost=i686-pc-linux-gnu \
--cross-file glib.cross \
My cross-file that is fed to meson on the configure line.
system = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

c_args = ['-m32' , '-Dhost=i686-pc-linux-gnu']
c_link_args = []
cpp_args = ['-m32' , '-Dhost=i686-pc-linux-gnu']
cpp_link_args = []

c = 'gcc'
cpp = 'g++'
ar = 'ar'
strip = 'strip'
pkgconfig = 'pkg-config'
windres = 'windres'
Old 05-29-2019, 03:21 PM   #2
Registered: Apr 2015
Posts: 103

Original Poster
Rep: Reputation: Disabled
Glib's page on cross-compiling.
Meson's page on cross-compiling.
Old 05-29-2019, 09:43 PM   #3
Registered: Nov 2017
Location: Malaysia
Distribution: Venom Linux
Posts: 47

Rep: Reputation: Disabled
You need patch glib to make multilib support.
Check here to see how i build 32bit glib
1 members found this post helpful.
Old 05-30-2019, 03:52 AM   #4
Registered: Apr 2015
Posts: 103

Original Poster
Rep: Reputation: Disabled
Thanks for that! WOW!

I thought that it might be GLIB. Other meson based
packages that I ran into compiled fine with 32-bit.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Which package should provide ninja and meson? Lennie Linux From Scratch 6 12-29-2017 02:01 AM
LXer: GNOME 3.28 Desktop Environment Gets Third Development Snapshot, More Meson Ports LXer Syndicated Linux News 0 12-17-2017 04:56 AM
[SOLVED] Meson sr_ls_boy Linux From Scratch 4 10-07-2017 05:52 AM
LXer: The Road to GTK+ 4 Continues, New Milestone Adds Initial OS X and Meson Support LXer Syndicated Linux News 0 05-24-2017 07:27 PM > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 06:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration