Page 1 of 1

"strptime" don't get compiled

Posted: Tue Nov 14, 2017 4:12 pm
by Gfast2
Hi ESP-IDF,

today I have another issue, my toolchian can't figure out what is strptime. I've did some research on this. Some one said, it is not a standard C function, but a POSIX standard function. And my elcipse did successful found this function in <time.h>. But ESP-IDF still won't compile.

Any tipp for me?

Code: Select all

#include <stdio.h>
#include <time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

void app_main()
{
    printf("Hello world!\n");
    
    struct tm tm;
    strptime("2017-11-11T11:11:11ZZ", "%y-%m-%dT%H:%M:%SZZ", &tm);
}  
Error Log:

Code: Select all

/home/gfast2/esp/esp-idf/examples/get-started/hello_world/build/main/libmain.a(hello_world_main.o):(.literal.app_main+0xc): undefined reference to `strptime'
/home/gfast2/esp/esp-idf/examples/get-started/hello_world/build/main/libmain.a(hello_world_main.o): In function `app_main':
/home/gfast2/esp/esp-idf/examples/get-started/hello_world/main/./hello_world_main.c:11: undefined reference to `strptime'
collect2: error: ld returned 1 exit status
/home/gfast2/esp/esp-idf/make/project.mk:372: recipe for target '/home/gfast2/esp/esp-idf/examples/get-started/hello_world/build/hello-world.elf' failed
make: *** [/home/gfast2/esp/esp-idf/examples/get-started/hello_world/build/hello-world.elf] Error 1

Re: "strptime" don't get compiled

Posted: Wed Nov 15, 2017 6:31 am
by ESP_Angus
Hi Gfast2,

Thanks for reporting this. This is a bug in IDF. The file is compiling correctly but linking is failing because strptime() is missing from the libc library. We are working on a fix.

Angus

Re: "strptime" don't get compiled

Posted: Wed Nov 15, 2017 8:58 am
by Gfast2
Thanks Angus,

As the work around, I use "sscanf()" which works on ESP-IDF right now, for someone who has the same problem right now. :)

cheers

Gfast2

Re: "strptime" don't get compiled

Posted: Thu Nov 16, 2017 10:38 pm
by ESP_Angus
Glad you found a workaround. On the current IDF master branch (as of 7e8c2a9), strptime() will link correctly.