我的代码在这里:
#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计算机有关?
谢谢!
发布于 2014-03-26 16:08:36
ucontext.h和semaphore.h是linux-headers linux包的一部分。我不认为你能够在Windows上编译这个应用程序。安装一个带有Linux的虚拟机,并尝试在那里编译。
发布于 2014-03-26 16:16:50
假设你在/path/to/dir中有semaphore.h和/或ucontext.h,你可以在gcc中添加选项-I/path/to/dir来解决这个问题。
顺便说一下,semaphore.h和ucontex.h是Glibc的一部分,通过正确安装的GNU工具链,gcc应该能够在没有任何额外选项的情况下找到它们。
https://stackoverflow.com/questions/22654679
复制相似问题