Loading...
 
Skip to main content

System Workbench for STM32


Linker Problem: undefined reference to `__errno'

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.

build log:
'Building target: STM32F429I_DISCO_MB1075.elf'
'Invoking: MCU GCC Linker'
arm-none-eabi-gcc -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 -o "STM32F429I_DISCO_MB1075.elf" ./Middlewares/STemWin/Config/GUIConf.o ./Middlewares/STemWin/Config/GUI_X.o ./Middlewares/STemWin/Config/LCDConf_stm32f429i_disco_MB1075.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_cortex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_crc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_dma.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_dma2d.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_flash.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_flash_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_gpio.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_i2c.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_i2c_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_i2s.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_i2s_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_ltdc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_pwr.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_pwr_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_rcc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_rcc_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_rtc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_rtc_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_sdram.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_spi.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_tim.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_tim_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_uart.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_ll_fmc.o ./Drivers/CMSIS/system_stm32f4xx.o ./Drivers/BSP/STM324x9I_DISCO/stm32f429i_discovery.o ./Drivers/BSP/STM324x9I_DISCO/stm32f429i_discovery_io.o ./Drivers/BSP/STM324x9I_DISCO/stm32f429i_discovery_sdram.o ./Drivers/BSP/STM324x9I_DISCO/stm32f429i_discovery_ts.o ./Drivers/BSP/Components/ili9341.o ./Drivers/BSP/Components/stmpe811.o ./Application/User/calibration.o ./Application/User/main.o ./Application/User/rtc.o ./Application/User/stm32f4xx_it.o ./Application/SW4STM32/startup_stm32f429xx.o ./Application/Demo/GUIDEMO.o ./Application/Demo/GUIDEMO_AntialiasedText.o ./Application/Demo/GUIDEMO_Automotive.o ./Application/Demo/GUIDEMO_BarGraph.o ./Application/Demo/GUIDEMO_Bitmap.o ./Application/Demo/GUIDEMO_ColorBar.o ./Application/Demo/GUIDEMO_Conf.o ./Application/Demo/GUIDEMO_Cursor.o ./Application/Demo/GUIDEMO_Fading.o ./Application/Demo/GUIDEMO_Graph.o ./Application/Demo/GUIDEMO_IconView.o ./Application/Demo/GUIDEMO_ImageFlow.o ./Application/Demo/GUIDEMO_Intro.o ./Application/Demo/GUIDEMO_Listview.o ./Application/Demo/GUIDEMO_RadialMenu.o ./Application/Demo/GUIDEMO_Resource.o ./Application/Demo/GUIDEMO_Skinning.o ./Application/Demo/GUIDEMO_Speed.o ./Application/Demo/GUIDEMO_Speedometer.o ./Application/Demo/GUIDEMO_Start.o ./Application/Demo/GUIDEMO_TransparentDialog.o ./Application/Demo/GUIDEMO_Treeview.o ./Application/Demo/GUIDEMO_VScreen.o ./Application/Demo/GUIDEMO_WashingMachine.o ./Application/Demo/GUIDEMO_ZoomAndRotate.o ./Application/Demo/syscalls.o -l:STemWin528_CM4_GCC.a
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu\libm.a(lib_a-w_sqrt.o): In function `sqrt':
w_sqrt.c:(.text.sqrt+0x9e): undefined reference to `__errno'
w_sqrt.c:(.text.sqrt+0xa8): undefined reference to `__errno'
collect2.exe: error: ld returned 1 exit status
make: *** STM32F429I_DISCO_MB1075.elf Error 1



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 ๐Ÿ˜‘

P.P.S. Intestingly, my own project throws the same error if I include the sqrt function, but not with other maths functions (sin() etc.), but the demo project still throws the error, referencing sqrt, even if I delete all use of sqrt from the project...???

include the clib before mlib. Do not use the "Use C math library" check box. It puts mlib first in the linker command line. I have tried to upload a screen shot of the linker settings, but its not working for me.

This solution (unchecking "Use C math library") does not work:(
If put ั‹ะนะบะต(9)ะฑ for example, it goes though,. If use a float or double variable - the problem appears.
Any other ideas?


Actualy it does not matter whether "Use C math library" checked or unchecked, path to the library libm.a should be set in the "Library search path (-L)" and libraries clib (c) and mlib (m) should be set one after other.
See the attached picture.
The path to the library in my case
"E:\Design\Ac6\SystemWorkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.7.0.201602121829\tools\compiler\arm-none-eabi\lib\thumb"


Hello
I have a simular Problem
w_asin.c:(.text.asin+0xa8): undefined reference to `__errno'

The last Post did't help!


Here are the following steps I used :
โ€ข Download the STM32Cube_FW_F4_V1.13.0 Firware Package;
โ€ข Target the STemWin_SampleDemo application in ...\STM32Cube_FW_F4_V1.13.0\Projects\STM32F429I-Discovery\Applications\STemWin\ folder;

Then :
โ€ข Launch SW4STM32 and select the workspace = ......\STM32Cube_FW_F4_V1.13.0\Projects\STM32F429I-Discovery\Applications\STemWin\STemWin_SampleDemo\SW4STM32;
โ€ข Right-click in the project explorer >> Import >> General >> Existing Projects into Workspace >> Browse >> Select STM32F429I_DISCO_MB1075 folder >> Finish;
โ€ข Launch compilation (no need to add extra settings) : Build finished successfully without error;


I experienced the same error using pow10() in SW4STM32 with gcc and STM32F030. Adding the mlib and unchecking the "Use C math library" fixed it. Adding the clib didn't seem to be necessary.

Hi, I reproduced this issue in excluding from build the syscalls.c.
The fix I used : -specs=rdimon.specs and -specs=nosys.specs in the linker flags


The way Chudik suggested to do (like on his attached screenshot, add "c" and then "m" library) did help me ! =) Great !! Thanks !

 
Collapse/expand modules below