在 Debian(以及一般的 Linux/Unix)里,copendir 这个函数是不存在的,所以你“找不到”是非常正常的。
opendir你可能想用的是:
#include <dirent.h>
DIR *opendir(const char *name);
示例:
#include <stdio.h>
#include <dirent.h>
int main() {
DIR *dir = opendir(".");
if (!dir) {
perror("opendir");
return 1;
}
// 使用 readdir 等
closedir(dir);
return 0;
}
编译:
gcc test.c -o test
常见原因:
opendir,没有 copendir 属于 POSIX 接口(<dirent.h>)opendir 只能打开目录流,不能复制目录。
复制目录一般用:
cp -ropendir + readdir + 递归 + mkdir + open/read/write确保安装了 man 和开发文档:
sudo apt update
sudo apt install manpages manpages-dev
man opendir
如果你能贴一下:
我可以更精确地告诉你问题出在哪。