【问题标题】:Cannot compile pyethash python package which requires C99 compiler (AFAIU). Error - Cannot open include file: 'alloca.h'无法编译需要 C99 编译器 (AFAIU) 的 pyethash python 包。错误 - 无法打开包含文件:'alloca.h'
【发布时间】:2016-12-07 00:15:36
【问题描述】:

问题

当手动或使用 pip 安装 pyethash 时,我得到了同样的错误:

致命错误 C1083:无法打开包含文件:'alloca.h':没有这样的文件 或目录错误:命令 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe' 失败,退出状态为 2

相关并已尝试:

没有答案的类似问题:

其他事实:

  • 成功安装需要 C++ 编译器的 Crypto 和 scrypt。
  • pyethash core.c 源文件头中还提到了另外 3 个文件,这些文件在我的驱动器上的任何地方都不存在:
    • alloca.h
    • stdint.h
    • stdlib.h

系统

python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)], windows 8.1 x64

...\ethash-master> python setup.py install

PS C:\pyethereum\ethash-master> python setup.py install
running install
running build
running build_ext
building 'pyethash' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python2
7\include -IC:\Python27\PC /Tcsrc/python/core.c /Fobuild\temp.win-amd64-2.7\Release\src/python/core.obj -Isrc/ -std=gnu9
9 -Wall
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
core.c
c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(81) : warning C4820: 'Pre
Attribute' : '4' bytes padding added after data member 'Access'
c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(96) : warning C4820: 'Pre
Attribute' : '4' bytes padding added after data member 'NullTerminated'
c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(112) : warning C4820: 'Po
stAttribute' : '4' bytes padding added after data member 'Access'
c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(191) : warning C4820: 'Pr
eRangeAttribute' : '4' bytes padding added after data member 'Deref'
c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(203) : warning C4820: 'Po
stRangeAttribute' : '4' bytes padding added after data member 'Deref'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(60) : warning C4820: '_finddata32i64_t' : '4' bytes p
adding added after data member 'name'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(64) : warning C4820: '_finddata64i32_t' : '4' bytes p
adding added after data member 'attrib'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(73) : warning C4820: '__finddata64_t' : '4' bytes pad
ding added after data member 'attrib'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(78) : warning C4820: '__finddata64_t' : '4' bytes pad
ding added after data member 'name'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(126) : warning C4820: '_wfinddata64i32_t' : '4' bytes
 padding added after data member 'attrib'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(131) : warning C4820: '_wfinddata64i32_t' : '4' bytes
 padding added after data member 'name'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(135) : warning C4820: '_wfinddata64_t' : '4' bytes pa
dding added after data member 'attrib'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\basetsd.h(114) : warning C4668: '__midl' is not defined as a prepro
cessor macro, replacing with '0' for '#if/#elif'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\basetsd.h(424) : warning C4668: '_WIN32_WINNT' is not defined as a
preprocessor macro, replacing with '0' for '#if/#elif'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\stdio.h(62) : warning C4820: '_iobuf' : '4' bytes padding
added after data member '_cnt'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\stdio.h(381) : warning C4255: '_get_printf_count_output' :
 no function prototype given: converting '()' to '(void)'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\stdlib.h(215) : warning C4255: '_get_purecall_handler' : n
o function prototype given: converting '()' to '(void)'
c:\python27\include\pyport.h(206) : warning C4668: 'SIZEOF_PID_T' is not defined as a preprocessor macro, replacing with
 '0' for '#if/#elif'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(41) : warning C4820: '_exception' : '4' bytes paddi
ng added after data member 'type'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(111) : warning C4820: '_stat32' : '2' bytes pad
ding added after data member 'st_gid'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(127) : warning C4820: 'stat' : '2' bytes paddin
g added after data member 'st_gid'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(143) : warning C4820: '_stat32i64' : '2' bytes
padding added after data member 'st_gid'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(144) : warning C4820: '_stat32i64' : '4' bytes
padding added after data member 'st_rdev'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(148) : warning C4820: '_stat32i64' : '4' bytes
padding added after data member 'st_ctime'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(157) : warning C4820: '_stat64i32' : '2' bytes
padding added after data member 'st_gid'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(171) : warning C4820: '_stat64' : '2' bytes pad
ding added after data member 'st_gid'
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\sys/stat.h(172) : warning C4820: '_stat64' : '4' bytes pad
ding added after data member 'st_rdev'
c:\python27\include\object.h(358) : warning C4820: '_typeobject' : '4' bytes padding added after data member 'tp_flags'
c:\python27\include\object.h(411) : warning C4820: '_typeobject' : '4' bytes padding added after data member 'tp_version
_tag'
c:\python27\include\unicodeobject.h(420) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'h
ash'
c:\python27\include\intobject.h(26) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'ob_iva
l'
c:\python27\include\stringobject.h(49) : warning C4820: '<unnamed-tag>' : '7' bytes padding added after data member 'ob_
sval'
c:\python27\include\bytearrayobject.h(26) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member '
ob_exports'
c:\python27\include\setobject.h(26) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'hash'
c:\python27\include\setobject.h(56) : warning C4820: '_setobject' : '4' bytes padding added after data member 'hash'
c:\python27\include\methodobject.h(42) : warning C4820: 'PyMethodDef' : '4' bytes padding added after data member 'ml_fl
ags'
c:\python27\include\fileobject.h(26) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'f_ski
pnextlf'
c:\python27\include\fileobject.h(33) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'writa
ble'
c:\python27\include\genobject.h(23) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'gi_run
ning'
c:\python27\include\descrobject.h(28) : warning C4820: 'wrapperbase' : '4' bytes padding added after data member 'offset
'
c:\python27\include\descrobject.h(32) : warning C4820: 'wrapperbase' : '4' bytes padding added after data member 'flags'

c:\python27\include\weakrefobject.h(37) : warning C4820: '_PyWeakReference' : '4' bytes padding added after data member
'hash'
c:\python27\include\pystate.h(70) : warning C4820: '_ts' : '4' bytes padding added after data member 'use_tracing'
c:\python27\include\import.h(61) : warning C4820: '_frozen' : '4' bytes padding added after data member 'size'
c:\python27\include\code.h(26) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'co_firstlin
eno'
src/python/core.c(2) : fatal error C1083: Cannot open include file: 'alloca.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

问题

如何编译这个包? (请帮忙,现在是第 4 天!)

【问题讨论】:

  • &lt;stdintl.h&gt;stdlib.h 是标准 C 库头文件。它们应该可以在任何声称拥有 C 编译器的系统上找到。 alloca.h 不在任何标准中,既不是 C99 也不是 POSIX,但经常在类似 POSIX 的系统上找到。它的功能被 C99 的可变长度数组取代,所以我不认为 C99 是你的问题。我个人不会相信任何使用它的软件。

标签: python c++ c compiler-errors c99


【解决方案1】:

alloca allocates a自动记忆,正如 Jens Gustedt 所说,它不是标准化的。

MSVCRT 在&lt;malloc.h&gt; header 中声明它。它在 Windows 上的实现与 UNIX 系统上的常见行为一致,因此它应该可以按预期工作。代码的其他部分可能更紧密地与 UNIX 耦合,可能需要重写。

另外两个头文件是标准 C 头文件,应该位于编译器自动搜索的 INCLUDE 目录中。

【讨论】:

    【解决方案2】:

    如果您的 Python 2.7 解释器是使用最新版本编译的(就像您的版本,即 [MSC v.1500 64 bit (AMD64)]),您可以安装更新版本的 MSVC(Visual Studio 社区版是免费的)并修改 Python 2.7 的 msvxx99 .py,直接在文件&lt;python&gt;/lib/distutils/msvc9compiler.py中的find_vcvarsall函数的开头插入以下内容(其中&lt;python&gt;通常是C:\Python27或类似的)。这应该可以解决任何 Python 2 模块的问题。

    请注意,如果您的安装位于C: 以外的驱动器上,则需要更改路径。代码故意简单,并没有尝试通过使用注册表或vswhere 等变得聪明,如果找不到更新版本的 MSVC,将回退到原始实现。

    def find_vcvarsall(version):
        # --[insert starts here]--
        import glob
        paths = glob.glob(r"C:\Program Files (x86)\Microsoft Visual Studio\20*\*\vc\Auxiliary\Build\vcvarsall.bat")
        if paths:
            print("{} possible locations for vcvarsall.bat found:".format(len(paths)))
            for i, path in enumerate(paths):
                print("\t[{}] {}".format(i, path))
            if len(paths) > 1:
                print("picking one at random:")
                paths.shuffle()
            path = paths[0]
            print("selecting:  {}".format(path))
            return path
    
        # otherwise, do what it would have done normally
    

    【讨论】:

      猜你喜欢
      • 2016-12-02
      • 1970-01-01
      • 2012-09-04
      • 2015-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-13
      相关资源
      最近更新 更多