Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
github-rkaiser opened this issue Sep 13, 2023 · 2 comments · Fixed by #2151
Closed

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

github-rkaiser opened this issue Sep 13, 2023 · 2 comments · Fixed by #2151
Labels
enhancement New feature or request waiting feedback Further information is required
Milestone

Comments

@github-rkaiser
Copy link

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 fpistm added enhancement New feature or request New feature labels Sep 14, 2023
@fpistm
Copy link
Member

fpistm commented Sep 14, 2023

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

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:

  • based on the number of milliseconds passed since the board began running the current program (millis());
  • based on RTC and the epoch time which will required to have STM32RTC library dependency.

@fpistm fpistm added the waiting feedback Further information is required label Sep 18, 2023
@fpistm
Copy link
Member

fpistm commented Sep 19, 2023

@github-rkaiser
any though on my previous comment?

@fpistm fpistm added this to the 2.7.0 milestone Oct 25, 2023
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Oct 25, 2023
Fixes stm32duino#2129.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
fpistm added a commit that referenced this issue Oct 26, 2023
Fixes #2129.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting feedback Further information is required
Projects
Development

Successfully merging a pull request may close this issue.

2 participants