1

I've attempted (using my limited Linux skillset) to cross-compile the NTFS-3G drivers for Angstrom Linux running on an ARMv7 platform.

I tried the following configure thinking that it worked:

./configure --target=arm-angstrom-linux-gnueabihf --host=arm-angstrom-linux-gnueabi --prefix=/dev/build_ntfs
make
sudo make install

I then copied the resulting installation onto the rootfs of my embedded platform only to find that when I execute one of the tools built with NTFS-3G, I get the following error:

ntfsls: cannot execute binary file: Exec format error

When I do file ntfsls, it comes back with:

ntfsls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24,
BuildID[sha1]=4eeb3c06c20046bedf70df6c774e32ddc89c097c, not stripped

Now obviously when I've done the configure, it hasn't picked up on the cross compiler. If I try file on another tool, such as minicom:

file minicom

The result is:

minicom: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically
linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32,
BuildID[sha1]=85d16f083bb06935bff73c248341a8d5fe22cdab, stripped

Which is clearly definitely built for ARM.

My question is, in which step have I failed to target the ARM platform?

sashoalm
  • 75,001
  • 122
  • 434
  • 781
weblar83
  • 681
  • 11
  • 32
  • 2
    Maybe try examining the configure.log or configure.status file, and try to figure out which compiler it selected. It would be strange for the configure flags not to have any effect, usually configure will fail. Try with `configure --foo=something` to see if it fails on unknown flags. – sashoalm Jun 20 '16 at 15:32
  • In the `config.log` it says: checking for arm-angstrom-linux-gnueabi-gcc result: no. On the next line it says: checking for gcc found: /usr/bin/gcc – weblar83 Jun 20 '16 at 15:34
  • So install that. On Ubuntu, just type `arm-angstrom-linux-gnueabi-gcc` at the terminal, and it should tell you that it's missing and which package to install to get it. – sashoalm Jun 20 '16 at 15:35
  • The toolchain is already installed. I've managed to build u-boot and the linux kernel with it already which works without issue. If I do `which arm-angstrom-linux-gnueabi-gcc` it shows the correct path – weblar83 Jun 20 '16 at 15:36
  • 2
    Then you need to troubleshoot `checking for arm-angstrom-linux-gnueabi-gcc`. Run the configure file in debug mode - https://stackoverflow.com/questions/951336/how-to-debug-a-bash-script. See how it performs the check. Or just open the `./configure` script in a text editor and search for `arm-angstrom-linux-gnueabi-gcc` and go from there. – sashoalm Jun 20 '16 at 15:39
  • Ok, I've figured out that my PATH variable was incorrect. That is now fixed and in the `config.log` the correct GCC compiler is found. I now have issues with `error: C compiler cannot create executables` – weblar83 Jun 20 '16 at 15:41
  • So looking further down the `config.log`, there are errors such as: `cannot open crt1.o: No such file or directory`, etc. – weblar83 Jun 20 '16 at 15:49
  • 2
    In an attempt to reproduce this, I've just downloaded the latest (2016.2.22) NTFS-3G source and cross-built it with the Linaro arm-linux-gnueabihf toolchain that was handy. Even with a nonsensical mismatch between host and target, even with a WTF prefix for installing into /dev/, I cannot prevent configure from succeeding. Thus I can only conclude that your environment and/or toolchain is, to use the technical term, utterly bollocksed ;) – Notlikethat Jun 20 '16 at 21:17
  • Ha, I like your technical term. I may well have discovered the answer and it lies in passing the sysroots path to the ./configure. I'm yet to try it but I'm hopeful it will work - the tool chain has been used to build the kernel and other modules so I know it is good. – weblar83 Jun 20 '16 at 22:14

1 Answers1

0

It might be worth checking that you have entered the command correctly - specifically look at "--host=arm-angstrom-linux-gnueabi" - should that be "--host=arm-angstrom-linux-gnueabihf" (note "hf" on the end to compile for an ARM chip with hardware floating point support)?

Just to verify I have tried this command

glen@gw2:~/tmp/ntfs-3g_ntfsprogs-2016.2.22$ ./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --prefix=$HOME/tmp/test

Which worked perfectly and creates ARM binaries:

glen@gw2:~/tmp/ntfs-3g_ntfsprogs-2016.2.22$ file ../test/lib/libntfs-3g.so.87.0.0
 ../test/lib/libntfs-3g.so.87.0.0: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=334b6214d2d68655d9dfd3bc518da927d9f1fa01, not stripped

If you can't get the Ångström compiler to work - maybe try one of the other ARM compilers?

Glen Walker
  • 71
  • 1
  • 3
  • I'm pretty sure the target is simply ignored in this case - I even tried the utterly impossible `--host=arm-linux-gnueabihf --target=aarch64-linux-gnu` and it still churned out ARMv7 binaries without complaint.... – Notlikethat Jun 21 '16 at 11:31
  • Yes you are correct - I have just checked without any "--target" specified and it still worked perfectly so it remains a mystery why weblar83 is having trouble! – Glen Walker Jun 21 '16 at 12:08
  • It looks as though its not picking up on the sysroots as the arm-angstrom-linux-gnueabi toolchain doesn't have the sysroot support built in. I'll try one of the other compilers. Cheers – weblar83 Jun 21 '16 at 15:27
  • I tried the gcc-linaro toolchain as suggested by the manufacturer of the platform however, this worked successfully up until the "make install" phase - every time it failed to build all of the packages. I then downloaded the arm-linux-gnueabihf compiler and everything has just worked perfectly - not tried the packages on my target hardware yet but all seems well. – weblar83 Jun 22 '16 at 19:23