Martin-Laclaustra / CronAlarms

Arduino IDE library for scheduling alarms to occur at specific times with crontab syntax
GNU Lesser General Public License v3.0
56 stars 29 forks source link

undefined reference to `_gettimeofday' #27

Open maxkraft7 opened 10 months ago

maxkraft7 commented 10 months ago

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?

Martin-Laclaustra commented 10 months ago

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.