How to use candian in Crosstools-NG in a cross-native fashion to get gcc on an arm board?

狂风中的少年 提交于 2019-12-06 07:22:36
hak8or

This answer is an extension of my original question regarding the general workflow for cross compiling a toolchain.

I had the correct general idea, you have to do a Canadian-Build with the host system tuple being the arm-unknown-linux-gnueabi cross compiler I made earlier. Make sure to include it to your path or do some symlinking into /bin or however else you want to handle that.

I had to wait roughly 30 minutes when doing the build using 3/4 cores of an I5-3570k and ~2GB of ram in a Ubuntu Vmware virtual machine using a normal HDD. Using a SSD will probably bump the speed up significantly.

Once this is done, you should be have an output directory that Crosstools-NG made for you which includes the toolchain for the ARM architectre. You can verify this by running file filename on any of the binaries.

Now, for the library situation which took me a while and gave a decent bit of confusion. In the toolchain output there should be a rootfs folder. That folder contains the expected root file system of the target for which you will be compiling (in this case arm). You need to copy the /lib folder as well as lib's from the user, mirroring the folder hierarchy of this rootfs folder.

You can verify if you have the libraries setup right by doing objdump -p filename and seeing the NEEDED entries which point to required libraries which should be in the rootfs.

If you are using a busybox based rootfs, then assuming you didn't statically compile it then you probably already have the libraries setup correctly since you needed them for busybox. I did a static build of busybox first to make sure I can get the system to boot to a shell, and then made a nonstatic build to have a soft start for libraries, using the libraries from the toolchains rootfs folder. Once I got a dynamically linked busybox system working, simply dropping the cross compiled toolchain into your rootfs at an arbitrary location (/usr/home/toolchain for me) should suffice, after which you should use the toolchain just the same as for an x86 system referring to path and symlinks and whatever you want to do.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!