python安装后无法打开文本_Python 安装zbar-py时出现 无法打开包括文件: “unistd.h” no such file or directory...

问题

途中使用的命令是cl.exe,在执行命令的时候找不到对应的unistd.h文件。

unistd.h是Unix系统的文件,因此,十有八九,使用的是Windows系统。下面的代码可以修复,但是如果修复了unistd.h,很大概率你还会有更多个*.h文件找不到。劝退。

解决

找到这个编译器所在的文件夹的include文件夹,并且unistd.h文件复制进去即可。可以新建一个文本文件,把名字和后缀名改为unistd.h。

#ifndef _UNISTD_H

#define _UNISTD_H 1

/* This is intended as a drop-in replacement for unistd.h on Windows.

* Please add functionality as neeeded.

* https://stackoverflow.com/a/826027/1202830

*/

#include

#include

#include /* getopt at: https://gist.github.com/ashelly/7776712 */

#include /* for getpid() and the exec..() family */

#include /* for _getcwd() and _chdir() */

#define srandom srand

#define random rand

/* Values for the second argument to access.

These may be OR'd together. */

#define R_OK 4 /* Test for read permission. */

#define W_OK 2 /* Test for write permission. */

//#define X_OK 1 /* execute permission - unsupported in windows*/

#define F_OK 0 /* Test for existence. */

#define access _access

#define dup2 _dup2

#define execve _execve

#define ftruncate _chsize

#define unlink _unlink

#define fileno _fileno

#define getcwd _getcwd

#define chdir _chdir

#define isatty _isatty

#define lseek _lseek

/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */

#ifdef _WIN64

#define ssize_t __int64

#else

#define ssize_t long

#endif

#define STDIN_FILENO 0

#define STDOUT_FILENO 1

#define STDERR_FILENO 2

/* should be in some equivalent to */

typedef __int8 int8_t;

typedef __int16 int16_t;

typedef __int32 int32_t;

typedef __int64 int64_t;

typedef unsigned __int8 uint8_t;

typedef unsigned __int16 uint16_t;

typedef unsigned __int32 uint32_t;

typedef unsigned __int64 uint64_t;

#endif /* unistd.h */

Windows的通病

这样是不可行的,在许多情况下。原因是这个头文件是unix, standard的缩写,只有unix系统(Linux, Mac OS)才有。因此我们需要找到对应的Windows标准库,就是 io.h,把包含是unistd.h的地方,都替换成io.h即可。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值