CronAlarms icon indicating copy to clipboard operation
CronAlarms copied to clipboard

undefined reference to `_gettimeofday'

Open maxkraft7 opened this issue 1 year ago • 1 comments

When I import CronAlarms.h and use Cron.create(...) in a platformio project where the board used is a STM Nucleo WB55 I get the following error:

<userpath>/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: <userpath>/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(lib_a-gettimeofdayr.o): in function `_gettimeofday_r':
gettimeofdayr.c:(.text._gettimeofday_r+0xe): undefined reference to `_gettimeofday'

This is the exact platformio.ini I'm using.

[env:nucleo_wb55rg_p]
platform = ststm32
board = nucleo_wb55rg_p
framework = arduino
lib_deps = 
    martin-laclaustra/CronAlarms@^0.1.0

if you use it with this code the error should be reproducible:

#include <CronAlarms.h>

void setup(){
    Cron.create("0 0 * * * *", [](){  }, false);
}

void loop(){
    Cron.delay(1000);
}

What can I do about this?

maxkraft7 avatar Jan 03 '24 12:01 maxkraft7

As it is stated in the README, this library depends on ctime library, provided by SDKs. That error means that in the platformio support for the STM Nucleo WB55, these functions are not implemented or incorrectly linked. To test and to document that, you can try to compile several basic scripts (example scripts, not this library) that make use of time functions (take the examples from other microcontrollers) to see what works and what does not. Then, with that information, notify platformio or the developers of the core for the STM Nucleo WB55. I am afraid that until that is fixed, you will not be able to use this library as it is. The only alternative is that you fork the code and dig into it to substitute the absent functions for those that are actually available for the STM Nucleo WB55.

Martin-Laclaustra avatar Jan 04 '24 11:01 Martin-Laclaustra