15

I had the below error while cross compiling a helloworld program on 64 bit Ubuntu 16.04, for 32 bit Cortex A9 platform.

$ make /usr/local/comp/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mtune=cortex-a9 --sysroot=/usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -Iinclude -Wall -O3 -c -o main.o main.c In file included from /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/features.h:389:0, from /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/stdio.h:27, from main.c:5: /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/gnu/stubs.h:7:29: fatal error: gnu/stubs-soft.h: No such file or directory # include <gnu/stubs-soft.h> ^ compilation terminated. makefile:45: recipe for target 'main.o' failed make: *** [main.o] Error 1 

Then I examine the content of the stubs.h file:

$ cat /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/gnu/stubs.h /* This file is automatically generated. This file selects the right generated file of `__stub_FUNCTION' macros based on the architecture being compiled for. */ #if !defined __ARM_PCS_VFP # include <gnu/stubs-soft.h> #endif #if defined __ARM_PCS_VFP # include <gnu/stubs-hard.h> #endif 

Shall I define the _ARM_PCS_VFP in the makefile?

3
  • 1
    Is this Yocto? Have you sourced the environment file provided with the SDK (probably /usr/local/comp/poky/1.7/environment-something (use tab completion)? Commented Mar 6, 2018 at 20:15
  • 1
    Thanks Steve, $ source /usr/local/comp/poky/1.7/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi works. I can see the -mfloat-abi=hard is enabled inside that file. Commented Mar 6, 2018 at 20:28
  • After having sourced the environment, you shall use $CC to call gcc, in order to have every parameters required by the toolchain, like -mfloat-abi=hard. Commented Jan 17 at 13:47

2 Answers 2

23

From the name of your cross compiler, "cortexa9hf-vfp-neon-poky-linux-gnueabi", it targets the Cortex-A9 with VFP architecture and neon enabled. Adding -mfloat-abi=hard switch should solve the problem.

From GCC manual:

-mfloat-abi=name:

Specifies which floating-point ABI to use. Permissible values are: ‘soft’, ‘softfp’ and ‘hard’.

Specifying ‘soft’ causes GCC to generate output containing library calls for floating-point operations. ‘softfp’ allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions. ‘hard’ allows generation of floating-point instructions and uses FPU-specific calling conventions.

The default depends on the specific target configuration. Note that the hard-float and soft-float ABIs are not link-compatible; you must compile your entire program with the same ABI, and link with a compatible set of libraries.

Sign up to request clarification or add additional context in comments.

1 Comment

I am new to this cross compiler stuff, where do I place the -m in an eclipse setting?
2

To define, which package is missing, run the command

sudo apt-file search stubs-soft.h 

It shows that package libc6-dev-armel-cross contains the file stubs-soft.h So, install missing package by command

sudo apt-get install libc6-dev-armel-cross 

It will provide the file stubs-soft.h for the local machine

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.