【问题标题】:No such file found with semaphore.h and ucontext.h在 semaphore.h 和 ucontext.h 中找不到此类文件
【发布时间】:2014-03-26 07:55:42
【问题描述】:

我的代码在这里:

#define _GNU_SOURCE

#include "lib-ult.h"

#include <stdio.h>
#include <stdlib.h>

#include <ucontext.h>
#include <semaphore.h>

#define TRUE 1
#define FALSE 0
#define FAILURE -1

typedef struct Node {
    ucontext_t* context;
    int priority;

    struct Node* next;
    struct Node* prev;
} Node;

int STACK_SIZE = 16384;

sem_t queueLock;

sem_t threadsLock;

当我尝试构建项目时,我得到了Error 1 error C1083: Cannot open include file: 'ucontext.h': No such file or directory(以及 semaphore.h)。

这是为什么?我如何解决它?这与我有一台 Windows 机器有关吗?

谢谢!

【问题讨论】:

  • 如何编译这个源文件?

标签: c semaphore ucontext


【解决方案1】:

ucontext.hsemaphore.hlinux-headers linux 软件包的一部分。我认为您无法在 Windows 上编译此应用程序。用 Linux 安装一个虚拟机并尝试在那里编译。

【讨论】:

    【解决方案2】:

    假设您在/path/to/dir 中有semaphore.h 和/或ucontext.h,您可以在gcc 中添加选项-I/path/to/dir 来解决此问题。

    顺便说一句,semaphore.hucontex.h 是 Glibc 的一部分,具有正确安装的 GNU 工具链,gcc 应该能够在没有任何其他选项的情况下找到它们。

    【讨论】:

    • -L 是库路径不包括路径(-1)
    猜你喜欢
    • 1970-01-01
    • 2021-10-16
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2012-06-18
    • 2017-08-04
    相关资源
    最近更新 更多