Link error passing double variable to sqrt function
I’m using the STemWin_HelloWorld demo project for STM32746G-Discovery in STM32Cube_FW_F4_V1.8.0 as Template.
Modifying BASIC_HelloWorld.c with function sqrt.
Passing a number to function sqrt is OK.
Passing the name of a double variable to function sqrt gives the error:
09:56:41 **** Incremental Build of configuration Debug for project STM32746G_DISCOVERY ****
make all
‘Building file: D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Src/BASIC_HelloWorld.c’
‘Invoking: MCU GCC Compiler’
D:\STM32Cube_FW_F7_V1.3.0\Projects\STM32746G-Discovery\Applications\STemWin\STemWin_HelloWorld\SW4STM32\STM32746G_DISCOVERY\Debug
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -DUSE_HAL_DRIVER -DSTM32F746xx -DUSE_STM32756G_DISCOVERY -I”D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Inc” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/CMSIS/Device/ST/STM32F7xx/Include” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/CMSIS/Include” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/STM32F7xx_HAL_Driver/Inc” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/BSP/STM32746G-Discovery” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/BSP/Components/Common” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/BSP/Components” -I”D:/STM32Cube_FW_F7_V1.3.0/Middlewares/ST/STemWin/inc” -I”D:/STM32Cube_FW_F7_V1.3.0/Utilities” -I”D:/STM32Cube_FW_F7_V1.3.0/Utilities/Fonts” -Os -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP -MF”Application/User/BASIC_HelloWorld.d” -MT”Application/User/BASIC_HelloWorld.o” -o “Application/User/BASIC_HelloWorld.o” “D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Src/BASIC_HelloWorld.c”
‘Finished building: D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Src/BASIC_HelloWorld.c’
’ ’
‘Building target: STM32746G_DISCOVERY.elf’
‘Invoking: MCU GCC Linker’
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -L”D:\STM32Cube_FW_F7_V1.3.0\Middlewares\ST\STemWin\Lib” -specs=nosys.specs -specs=nano.specs -T”../STM32F746NGHx_FLASH.ld” -Wl,-Map=output.map -Wl,--gc-sections -lm -o “STM32746G_DISCOVERY.elf” @”objects.list” -l:STemWin528_CM7_GCC.a
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.7.0.201602121829/tools/compiler/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\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: *** STM32746G_DISCOVERY.elf Error 1
09:56:42 Build Finished (took 891ms)
Using GNU Tools for ARM Embedded Processors 5.3 2016q1
Following the modified file BASIC_HelloWorld.c
/*********************************************************************
- SEGGER MICROCONTROLLER SYSTEME GmbH *
- Solutions for real time microcontroller applications *
**********************************************************************
- *
- (c) 1996 - 2004 SEGGER Microcontroller Systeme GmbH *
- *
- Internet: www.segger.com
Support: support at segger.com *
- *
**********************************************************************
- emWin - Graphical user interface for embedded applications *****
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
--------------------------
File : BASIC_HelloWorld.c
Purpose : Simple demo drawing “Hello world”
--------------------------
- /
- include “GUI.h”
- include “math.h”
/*********************************************************************
- Public code
**********************************************************************
- /
/*********************************************************************
- MainTask
- /
double b = 25.0;
void MainTask(void) {
GUI_Clear();
GUI_SetFont(&GUI_Font20_1);
GUI_DispStringAt(“Hello world!\n”, (LCD_GetXSize()-100)/2, (LCD_GetYSize()-20)/2);
double a = sqrt(b); // link error with this
//double a = sqrt(25.0); // OK with this
GUI_DispFloat(a, 10);
while(1);
}
/*************************** End of file ****************************/
Please help using the sqrt function.