cancel
Showing results for 
Search instead for 
Did you mean: 

Linker Problem: undefined reference to `__errno'

daemynnur
Associate II
Posted on October 22, 2015 at 18:20

Hi,

I'm trying to get to grips with System Workbench for STM32 & STM32F429i-Disco board.

I'm trying to build the STemWin_SampleDemo project for STM32F429I-Discovery, supplied in STM32Cube_FW_F4_V1.8.0

but it comes up with a linker error :

w_sqrt.c:(.text.sqrt+0xa8): undefined reference to `__errno'

collect2.exe: error: ld returned 1 exit status

I've tried everything I can find suggested here & elsewhere ( mainly revolving around linking the math library with -lm, but this makes no difference.)

I was kinda hoping that a project supplied by ST from their STMcube suite using the ST (supplied?)  IDE would compile without issue so i could use it as a platform to work from.

Other projects, including the 'STM32F429I-Discovery' demonstration project, (also using the STemWin library) build & link without issue.

Linker Script: -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -L..\..\..\..\..\..\..\..\Middlewares\ST\STemWin\Lib -specs=nosys.specs -specs=nano.specs -T''..\STM32F429NIHx_FLASH.ld'' -Wl,-Map=output.map -Wl,--gc-sections -lm

Any ideas on how to resolve this would be welcome

TIA... Daemy

P.S. same project compiles without issue on a Keil/Arm compiler [but I don't have easy access to that :( ]

13 REPLIES 13
Dominic S
Associate
Posted on December 13, 2016 at 13:04

I had the same issue with SystemWorkbench. The solution that worked for me was simply to edit the project properties under C/C++ Build > Settings > Tool Settings > MCU GCC Linker > Libraries as follows:

- Uncheck 'Use C math library (-lm)'

- Add the math library manually to the libraries list by simply adding 'm'

This way the '-lm' part is moved to end of the make file instruction and it should compile properly.

Posted on February 09, 2017 at 21:59

Best Solution

Posted on July 10, 2017 at 12:45

THANK YOU!!!!!!!!!!

Ayoub Ayoub
Associate
Posted on August 23, 2017 at 14:22

Best Solution