undefined reference to `_gettimeofday' when compiling on a Teensy4.0
gannaramu opened this issue · 8 comments
I keep getting undefined reference to `_gettimeofday issue when importing the ArduinoBearSSL library.
undefined reference to `_gettimeofday'
Linking .pio\build\teensy40\firmware.elf
c:/users/ganna/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/fpu/fpv5-d16\libc.a(lib_a-gettimeofdayr.o): In function `_gettimeofday_r':
gettimeofdayr.c:(.text._gettimeofday_r+0x10): undefined reference to `_gettimeofday'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\teensy40\firmware.elf] Error 1
the fix mentioned arduino/Arduino#9413 seems to solve it.
But wanted to understand the reason for this issue? any help is appreciated.
Thanks
Imho this is something you should raise with @PaulStoffregen.
I've put this on my list of issues to investigate.
Sorry, can't look at it right now. I'm working on 3 urgent projects, all behind schedule. :(
It might be the case. Possible Teensy's platform defines cause BR_USE_UNIX_TIME to be set to 1 consequently requiring linking to _gettimeofday. In this case it would be as simple as adding a statement preventing this. @PaulStoffregen what would be a suitable define set in all Teensy platforms?
I do not know what compiler tag TEENSY defines, but in my port to the ESP32 I added
#if defined __unix__ || defined __linux__ || defined ESP32
and now it works like a charm.
My port to the ESP32 is here
I guess the teensy 4.x have the defines as:
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
Added _gettimeofday to Teensy 4.x core library.
PaulStoffregen/cores@50342d7
Added _gettimeofday to Teensy 4.x core library. PaulStoffregen/cores@50342d7
Thank you 🙇