2

I was trying to cross compile with autoconf. I had tried from these helps :

  1. https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Hosts-and-Cross_002dCompilation.html

  2. https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Specifying-Target-Triplets.html

  3. https://github.com/jedisct1/libsodium/issues/274
  4. Cross Compiling For ARM With Autoconf

And did -

./configure --build=x86_64-linux-gnu --host=/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf --target=/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf --disable-shared --disable-documentation

But after autoconf tool checking for the gcc and other things necessary for compilation it doesn't find these. Although they are already present in the directory.

So the log is :

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for /opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for /opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for /opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar... no
checking for /opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-lib... no
checking for /opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-link... no
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... x86_64-pc-linux-gnu
checking host system type... Invalid configuration `/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf': machine `/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm' not recognized
configure: error: /bin/bash ./config.sub /opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf failed

This is the directory for all arm toolchain bin

host@ubuntu:/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin$ ls
arm-linux-gnueabihf-addr2line  arm-linux-gnueabihf-gcc         arm-linux-gnueabihf-gfortran  arm-linux-gnueabihf-readelf
arm-linux-gnueabihf-ar         arm-linux-gnueabihf-gcc-5.4.1   arm-linux-gnueabihf-gprof     arm-linux-gnueabihf-size
arm-linux-gnueabihf-as         arm-linux-gnueabihf-gcc-ar      arm-linux-gnueabihf-ld        arm-linux-gnueabihf-strings
arm-linux-gnueabihf-c++        arm-linux-gnueabihf-gcc-nm      arm-linux-gnueabihf-ld.bfd    arm-linux-gnueabihf-strip
arm-linux-gnueabihf-c++filt    arm-linux-gnueabihf-gcc-ranlib  arm-linux-gnueabihf-nm        gdbserver
arm-linux-gnueabihf-cpp        arm-linux-gnueabihf-gcov        arm-linux-gnueabihf-objcopy   runtest
arm-linux-gnueabihf-elfedit    arm-linux-gnueabihf-gcov-tool   arm-linux-gnueabihf-objdump
arm-linux-gnueabihf-g++        arm-linux-gnueabihf-gdb         arm-linux-gnueabihf-ranlib

Any suggestion?

EDIT I tried the solution suggested by Chrono. It was able to find arm toolchain. But another problem arised :

error adding symbols: File format not recognized

libtool: link: arm-linux-gnueabihf-gcc -shared  -fPIC -DPIC  src/.libs/libcoap_1_la-address.o src/.libs/libcoap_1_la-async.o src/.libs/libcoap_1_la-block.o src/.libs/libcoap_1_la-coap_dtls.o src/.libs/libcoap_1_la-coap_event.o src/.libs/libcoap_1_la-coap_keystore.o src/.libs/libcoap_1_la-coap_time.o src/.libs/libcoap_1_la-debug.o src/.libs/libcoap_1_la-encode.o src/.libs/libcoap_1_la-hashkey.o src/.libs/libcoap_1_la-mem.o src/.libs/libcoap_1_la-net.o src/.libs/libcoap_1_la-option.o src/.libs/libcoap_1_la-pdu.o src/.libs/libcoap_1_la-resource.o src/.libs/libcoap_1_la-str.o src/.libs/libcoap_1_la-subscribe.o src/.libs/libcoap_1_la-uri.o src/platform/posix/.libs/libcoap_1_la-coap_io.o src/platform/posix/.libs/libcoap_1_la-prng.o src/platform/posix/.libs/libcoap_1_la-run.o   -L./ext/tinydtls -ltinydtls  -g -O2 -Wl,--version-script=./libcoap-1.map   -Wl,-soname -Wl,libcoap-1.so.0 -o .libs/libcoap-1.so.0.0.0

For this line of compilation the error is :

./ext/tinydtls/libtinydtls.a: error adding symbols: File format not recognized

EDIT 2:

The problem was with the library it is not passing the cross compiler params to the autoconf properly, hence the issue.

Community
  • 1
  • 1
ninja.stop
  • 410
  • 1
  • 10
  • 24
  • Possible duplicate of [Cross-compiling for ARM with Autoconf](https://stackoverflow.com/q/15234959/608639). – jww Oct 08 '18 at 12:25

1 Answers1

3

Ensure the directory containing your toolchain's binaries is in your $PATH:

export OLDPATH=$PATH
export PATH=$OLDPATH:/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin

You should only need to do that once, unless you log out or otherwise exit that terminal session.

With that done, you can configure properly:

./configure \
    --build=x86_64-linux-gnu \
    --host=arm-linux-gnueabihf \
    --target=arm-linux-gnueabihf \
    --disable-shared \
    --disable-documentation
  • It was able to find the crosscompile toolchains but another error came : error adding symbols: File format not recognized. Please see the edit – ninja.stop May 03 '17 at 08:47
  • 1
    The library I am compiling has another library inside . Through autoconf of the parent library , the child library autoconf is also being done. But in that case it is not taking arm crosstool from autocong. it is compiling with cc, not arm gcc. – ninja.stop May 03 '17 at 09:08
  • 1
    @ninja.stop That's something that would be better explored in a different question because additional details are needed (maybe it's a known issue with the library you're compiling?), but [this mailing list thread](https://dev.eclipse.org/mhonarc/lists/tinydtls-dev/msg00061.html) might be a good start. –  May 03 '17 at 09:35
  • True. It is a problem of that library indeed. Mailed them. As per the authors it is patched. let's see. BTW, thanks for the help :) – ninja.stop May 04 '17 at 05:49