stm32duino / Arduino_Core_STM32

STM32 core support for Arduino
https://github.com/stm32duino/Arduino_Core_STM32/wiki
Other
2.75k stars 958 forks source link

Linker error after using "std::chrono::steady_clock::now()" #2129

Closed github-rkaiser closed 10 months ago

github-rkaiser commented 11 months ago

If a am using

#  include <chrono>
...
std::chrono::steady_clock::now()

with a H745ZI, C031C6 or L476RG, I get the linker error

ld.exe: m-none-eabi\lib\thumb\v6-m\nofp\libc_nano.a(libc_a-gettimeofdayr.o): in function _gettimeofday_r
gettimeofdayr.c*: (.text._gettimeofday_r+0xe): undefined reference to _gettimeofday

collect2.exe*: error: ld returned 1 exit status

Error linking for board Nucleo-64 (STMicroelectronics_Nucleo_64)
Debug build failed for project 'STM32-C031C6' 

Please add he missing function to the library.

Thanks Richard

fpistm commented 11 months ago

Hi @github-rkaiser Thanks for this issue. Just a note, STM32 core is not a library :wink:

About your issue, _gettimeofday required to be implemented. Example to get the build successfull you can add this to your sketch:

extern "C" int _gettimeofday( struct timeval *tv, void *tzvp )
{
    return 0;  // return non-zero for error
}

Now, which implementation could be done:

fpistm commented 11 months ago

@github-rkaiser any though on my previous comment?