"strptime" don't get compiled

User avatar
Gfast2
Posts: 182
Joined: Fri Aug 11, 2017 1:52 am

"strptime" don't get compiled

Postby Gfast2 » Tue Nov 14, 2017 4:12 pm

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

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: "strptime" don't get compiled

Postby ESP_Angus » Wed Nov 15, 2017 6:31 am

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

User avatar
Gfast2
Posts: 182
Joined: Fri Aug 11, 2017 1:52 am

Re: "strptime" don't get compiled

Postby Gfast2 » Wed Nov 15, 2017 8:58 am

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

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: "strptime" don't get compiled

Postby ESP_Angus » Thu Nov 16, 2017 10:38 pm

Glad you found a workaround. On the current IDF master branch (as of 7e8c2a9), strptime() will link correctly.

Who is online

Users browsing this forum: Baidu [Spider] and 87 guests