gpt4 book ai didi

c - "Undefined reference to mknod "如何解决?

转载 作者:太空宇宙 更新时间:2023-11-04 04:36:35 24 4
gpt4 key购买 nike

/*Creating a special file */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char *argv[]){
int result;
if (argc != 2) {
fprintf(stderr, "Usage: ./a.out fifoname\n");
exit (1);
}
result = mknod (argv[1], S_IRUSR| S_IWUSR|S_IFIFO, 0);
if (result < 0) {
perror ("mknod");
exit (2);
}
}

我已经执行了一个示例代码来在使用 GCC 编译器的 CodeBlocks 中创建一个特殊文件......但是代码在 Ubuntu 环境中运行正常......是 Windows 环境造成的问题。如果是,如何解决在 Windows 中运行该程序的问题?

最佳答案

正如 qrdl 所指出的,mknod() 是一个 SVr4、4.4BSD、POSIX.1-2001 函数。但是,您可以包括 CoreUtil s 到 windows,将库添加到 codeblock 后,您可以使用这些功能。

关于c - "Undefined reference to mknod "如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30078654/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com