Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cross-compiling and building a simple Hello world application for running on Heterogenous architecture

I am new to ARM

I would like to cross-compile a simple Hello world c++ code for Linux distribution in order to debug and run it on my Hardkernel ODROID-XU4 board. For this purpose I'm following this tutorial https://developer.arm.com/tools-and-software/embedded/legacy-tools/ds-5-development-studio/resources/tutorials/linux-application-debugging-using-ds-5, however, instead of using the built-in compiler, I have downloaded the latest linaro gcc toolchain from this page https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads, I have windows 7 sp1. when I followed the steps mentioned in the tutorial, when I buit the project I encountered the following errors

11:32:29 **** Incremental Build of configuration Debug for project Hello_world_cpp ****
make all 
'Building file: ../Hello_wolrd.cpp'
'Invoking: GCC C++ Compiler 8.3.0 [arm-eabi]'
arm-eabi-g++.exe -mfpu=vfpv4 -O0 -g -Wall -marm -mfloat-abi=hard -MMD -MP -MF"Hello_wolrd.d" -MT"Hello_wolrd.o" -c -o "Hello_wolrd.o" "../Hello_wolrd.cpp"
'Finished building: ../Hello_wolrd.cpp'
' '
'Building target: Hello_world_cpp.axf'
'Invoking: GCC C++ Linker 8.3.0 [arm-eabi]'
arm-eabi-g++.exe  -o "Hello_world_cpp.axf"  ./Hello_wolrd.o   
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: error: ./Hello_wolrd.o uses VFP register arguments, Hello_world_cpp.axf does not
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: failed to merge target specific data of file ./Hello_wolrd.o
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-exit.o): in function `exit':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-abort.o): in function `abort':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/stdlib/abort.c:59: undefined reference to `_exit'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-signalr.o): in function `_kill_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/signalr.c:53: undefined reference to `_kill'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-signalr.o): in function `_getpid_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/signalr.c:83: undefined reference to `_getpid'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/sbrkr.c:51: undefined reference to `_sbrk'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-writer.o): in function `_write_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/writer.c:49: undefined reference to `_write'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-closer.o): in function `_close_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/closer.c:47: undefined reference to `_close'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-lseekr.o): in function `_lseek_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: undefined reference to `_lseek'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-readr.o): in function `_read_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/readr.c:49: undefined reference to `_read'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-fstatr.o): in function `_fstat_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/fstatr.c:55: undefined reference to `_fstat'
e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0/../../../../arm-eabi/bin/ld.exe: e:/programs/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/gcc-arm-8.3-2019.03-i686-mingw32-arm-eabi/bin/../lib/gcc/arm-eabi/8.3.0\libc.a(lib_a-isattyr.o): in function `_isatty_r':
/tmp/dgboter/bbs/dsggnu-vm-1-x86_64--mingw32-i686/buildbot/mingw32-i686--arm-eabi/build/src/newlib-cygwin/newlib/libc/reent/isattyr.c:52: undefined reference to `_isatty'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:46: Hello_world_cpp.axf] Error 1

11:32:31 Build Finished (took 1s.705ms)

How can solve this problem and build the program correctly and are the flages I'm using during compilation correct ?

  • Hi,

    The arm-eabi-g++ is a bare metal compiler (no operating system) and you are looking for a compiler to build a Linux application. 

    The one you want to use for 32-bit Linux applications is the on the same page: AArch32 target with hard float (arm-linux-gnueabihf)

    The DS-5 tutorial you reference does have this in the Toolchains pain if you look very close. 

    Let us know if you have any other questions.

    Thanks,

    Jason

  • Thanks for the answer, Actually I have figured that what you mentioned and switched to gcc arm-linux-gnueabihf 7.4.1. when I tried to build a simple c++ hello application to debug it on an ARM Linux target. I got the following error 

    19:10:30 **** Incremental Build of configuration Debug for project My_cpp_tutorial ****
    make all 
    'Building file: ../HelloWorld/My_cpp_tutorial.cpp'
    'Invoking: GCC C++ Compiler 7.4.1 [arm-linux-gnueabihf]'
    arm-linux-gnueabihf-g++.exe -I"E:\programs\gcc-linaro-7.4.1-2019.02-i686-mingw32_arm-linux-gnueabihf\gcc-linaro-7.4.1-2019.02-i686-mingw32_arm-linux-gnueabihf\arm-linux-gnueabihf\include\c++\7.4.1\arm-linux-gnueabihf" -I"E:\programs\gcc-linaro-7.4.1-2019.02-i686-mingw32_arm-linux-gnueabihf\gcc-linaro-7.4.1-2019.02-i686-mingw32_arm-linux-gnueabihf\arm-linux-gnueabihf\include\c++\7.4.1\arm-linux-gnueabihf\" -O0 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"HelloWorld/My_cpp_tutorial.d" -MT"HelloWorld/My_cpp_tutorial.o" -o "HelloWorld/My_cpp_tutorial.o" "../HelloWorld/My_cpp_tutorial.cpp"
    arm-linux-gnueabihf-g++.exe: fatal error: no input files
    compilation terminated.
    make: *** [HelloWorld/subdir.mk:20: HelloWorld/My_cpp_tutorial.o] Error 1
    
    19:10:31 Build Finished (took 432ms)

    What can I do, to resolve this error ?