【问题标题】:" Undefined reference to mknod " How to resolve this?“对 mknod 的未定义引用”如何解决这个问题?
【发布时间】:2015-07-16 16:52:23
【问题描述】:
/*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);
       }
  }

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

【问题讨论】:

  • mknod()是SVr4、4.4BSD、POSIX.1-2001函数,Windows都不支持,所以Windows标准库中根本不存在这个函数

标签: c windows gcc operating-system system-calls


【解决方案1】:

正如 qrdl 指出的,mknod() 是一个 SVr4、4.4BSD、POSIX.1-2001 函数。但是,您可以将CoreUtils 包含到 Windows 中,并且在将库添加到代码块后,您可以使用这些功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 2020-05-19
    • 1970-01-01
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    相关资源
    最近更新 更多