【发布时间】:2021-03-18 19:27:22
【问题描述】:
我正在使用esp-idf 进入ESP32,我想让一个程序能够在使用C 时运行子进程。
通常,我尝试调用如下函数:
...
#include <stdio.h>
char *cmd = "ls -l";
char buf[BUFSIZE];
FILE *fp;
if ((fp = popen(cmd, "r")) == NULL) {
printf("############## Error opening pipe!\n");
return -1;
}
while (fgets(buf, BUFSIZE, fp) != NULL) {
printf("############## OUTPUT: %s", buf);
}
if(pclose(fp)) {
printf("############## Command not found or exited with error status\n");
return -1;
}
return 0;
...
但应用程序返回
c:\esp\../main/app_main.c:139: undefined reference to `popen`
有人有这方面的经验吗?
【问题讨论】:
-
您使用的工具链最有可能用于“裸机”,因此并未实现所有标准库。
标签: c subprocess pipe esp32