对VS 2013和Cygwin使用fork() [英] Using fork() with VS 2013 and Cygwin
问题描述
我想写一个C程序,将在Visual Studio 2013中使用fork()和wait()。我已经下载并安装Cygwin,但我无法配置Visual Studio使用适当的头文件。我对IDE很新,我想知道这个社区是否可以帮我找出我在犯错误的地方。
I am trying to write a C program that will use fork() and wait() in Visual Studio 2013. I have downloaded and installed Cygwin, but I am unable to configure Visual Studio to use the appropriate header files. I'm fairly new to the IDE and I was wondering if this community could help me figure out where I am making a mistake.
当开始一个新项目时,我做什么:
When starting a new project, this is what I do:
- 创建新的Visual C ++ Win32控制台应用程序
- 添加新的main.c源文件到项目
- 右键单击项目属性并将包含目录配置为
,包括Cygwin目录:C:\cygwin64
我已经截图了我想要配置的属性,如果这是我在犯错误:
I've taken a screenshot of where I am trying to configure the properties in case this is where I am making my mistake:
我的代码很简单,因为我只是想让它运行在这个point:
My code is rather simple as I am just trying to get it to run at this point:
#include <unistd.h>
int main() {
int i;
i = fork();
if (i == 0) {
printf("I am the child.");
}
else {
wait(&i);
}
}
这是我收到的错误消息的屏幕截图尝试建立我的项目:
Here's a screenshot of the error message I receive when I try to build my project:
如果这是一个愚蠢的问题,我提前道歉,但我很感激你可以提供任何帮助。
I apologize in advance if this is a silly question, but I do appreciate any help that you can offer. If there is anything that I can do on my end to help troubleshoot, please let me know.
推荐答案
问题是,您的当前包含路径 C:\cygwin64\bin
等效于unix / bin
可执行文件)。要使用unix头,您需要使用等效的 / usr / include
,对于您的系统,应该是 C:\cygwin64\\ \\ usr \include
。
The problem is that your current include path C:\cygwin64\bin
is equivalent to unix /bin
, which is for binaries (aka executables). To use unix headers, you need to use the equivalent of /usr/include
, which, for your system, should be C:\cygwin64\usr\include
.
这篇关于对VS 2013和Cygwin使用fork()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!