linking libc
응답
15. 6. 29 오전 11:45
Hello everyone,

to use a simple timer I included time.h to my project. Calling functions from this file leads to a linker error:

c:/xdk-workbench/armgcc/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-gettimeofdayr.o): In function `_gettimeofday_r':
gettimeofdayr.c:(.text._gettimeofday_r+0xe): undefined reference to `_gettimeofday'


'_gettimeofday' is defined in libnosys.a in the same directory as libc.a. Even linking libnosys.a manually leads to the same error.
Did I do something wrong or is there anything special I have to consider? Or basically: how can I get time.h to work? ;-)

Thanks
Fredrik
0 (0 투표)
linking libc
응답
15. 6. 30 오후 2:39 as a reply to Fredrik Winzer.
Hi Fredrik,

the correct way to include an external library is as follows:
 
  • Go to your project properties>C/C++ Gerneral>Path and Symbols>Includes
  • There you can add a library with your file path

In your case there is a special problem with the time.h library and the getTimeOfDay function. If you want to implelement a functions like this, it have to be supported by the hardware.
The OS of the XDK „FreeRTOS“ is just a kernel, not a fully inflated operating system. Desktop computers have a day/time clock, however many small embedded systems don’t.
So the kernel FreeRTOS has no way to implement the getTimeOfDay function. Alternatively, if you have a network connection you might be able to avoid it using a NTP lib.
NPT is based on UPD, which is supported by the XDK.

Regards,
Manuel
0 (0 투표)
linking libc
응답
15. 6. 30 오후 2:49 as a reply to Manuel Cerny.
Hello Manuel,

thank you for your answer and your advice. I will search for a work around solution.

Regards
Fredrik
0 (0 투표)
linking libc
응답
15. 6. 30 오후 2:56 as a reply to Fredrik Winzer.
I'm sure there is a solution and you will find it.
If you have further questions, feel free to ask!

- Manuel
0 (0 투표)