C++ 无法打开包含文件:'unistd.h':没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22705751/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot open include file: 'unistd.h': No such file or directory
提问by user3471387
After having installed libpng
into my computer, I've included it into my project using #include <png.h>
on a Windows 7 SP1 plateform and using Visual Studio Ultimate 2013.
安装libpng
到我的计算机后,我已#include <png.h>
在 Windows 7 SP1 平台上使用 Visual Studio Ultimate 2013将其包含到我的项目中。
But at build time, I'm getting this error:
但是在构建时,我收到此错误:
C1083: Cannot open include file: 'unistd.h': No such file or directory
C1083:无法打开包含文件:'unistd.h':没有那个文件或目录
How do I please to fix this? I haven't found yet any solution in the net?
我该如何解决这个问题?我还没有在网上找到任何解决方案?
回答by Tony Delroy
The "uni" in unistd stands for "UNIX" - you won't find it on a Windows system.
unistd 中的“uni”代表“UNIX”——你不会在 Windows 系统上找到它。
Most widely used, portable libraries should offer alternative builds or detect the platform and only try to use headers/functions that will be provided, so it's worth checking documentation to see if you've missed some build step - e.g. perhaps running "make" instead of loading a ".sln" Visual C++ solution file.
最广泛使用的可移植库应该提供替代构建或检测平台,并且只尝试使用将提供的头文件/函数,因此值得检查文档以查看您是否错过了某些构建步骤 - 例如可能运行“make”代替加载“.sln”Visual C++ 解决方案文件。
If you need to fix it yourself, remove the include and see which functions are actually needed, then try to find a Windows equivalent.
如果您需要自己修复它,请删除包含并查看实际需要哪些功能,然后尝试找到 Windows 等效项。
回答by Grokking
If you're using ZLib in your project, then you need to find :
如果您在项目中使用 ZLib,那么您需要找到:
#if 1
in zconf.h and replace(uncomment) it with :
在 zconf.h 中并将其替换(取消注释)为:
#if HAVE_UNISTD_H /* ...the rest of the line
If it isn't ZLib I guess you should find some alternative way to do this. GL.
如果不是 ZLib,我想你应该找到一些替代方法来做到这一点。GL。