[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cross Compilation with CMake and mk-sbuild


Quoting Gustaf Waldemarson (2023-02-01 13:33:04)
> > I happen to be the maintainer of sbuild in Debian and I never heard of the
> > mk-sbuild tool. Where do you have this from and what does it do?
> Oh, it seems like I'm a bit off-base here:
> - https://wiki.debian.org/mk-sbuild
> It seems like `mk-sbuild` is actually some kind of wrapper script for Ubuntu,
> rather than a Debian tool, however it only seems to be direct convenience
> wrappers around `sbuild` and `schroot` as far as I can tell.

whoops... this page has not seen any real update since its creation in 2011. It
is horribly outdated and misleading... I added a big fat warning at the top.

> Oh interesting, this is all things I've pieced together from far arguably too
> many sources (basically from googling "cross compiling aarch64"), I went
> ahead and dug some of them up here just in case:
> -
> http://hypernephelist.com/2015/03/09/cross-compilation-made-easy-on-ubuntu-with-sbuild.html
> - https://discourse.cmake.org/t/linux-cross-compile-x64-to-aarch64/1752 -
> https://discourse.cmake.org/t/cross-compile-for-aarch64-on-ubuntu/2161 -
> https://github.com/rsenn/cmake-toolchains/blob/master/aarch64-linux-gnu.toolchain.cmake
> -
> https://github.com/sony/flutter-embedded-linux/blob/master/cmake/cross-toolchain-aarch64-template.cmake
> I had some previous experience with using sysroots for Android which is
> apparently still used extensively, so I didn't see anything all that wrong
> with using that for cross-compiling for other systems (Aarch64 in my case).
> Additionally, most of this worked just fine until I used `find_library`
> (which is recommended for CMake to get the -lm library) hence the confusion
> when everything stopped working.
> My main reason for using sysroots is really just to have an easy place to
> collect thirdparty packages from, which in my case are zlib, libpng,
> libOpenEXR and a few others, but from what you mention here it seems like a
> lot of this information is out-of-date or incorrect. I didn't really come
> across "mutliarch" at all while I was looking this up.

The idea of multiarch is, that you can install foreign architecture packages
(arm64 in your case) right next to the native architecture packages. That way,
your cross compiler will be able to find them without a sysroot directory.

> I did a bit more googling (using the multiarch keyword now). I guess this is
> a good place to read-up on using multiarch packages to download my
> dependencies?
> - https://wiki.debian.org/Multiarch/HOWTO

I've added an answer to your question
https://stackoverflow.com/a/75310713/784669 -- essentially, install a cross
compiler like g++-aarch64-linux-gnu or crossbuild-essential-arm64 (which will
pull in most of the cross-stuff) and then run CMake with the right arguments to
point it to your cross-compiler. If you need more libraries, just apt-get
install them as well by using the :arm64 suffix to the package name.


cheers, josch

Attachment: signature.asc
Description: signature

Reply to: