【发布时间】:2017-12-04 21:14:58
【问题描述】:
我已成功安装 Emscripten 并让它在 Ubuntu 16.04 虚拟机上运行。我还成功地将 helloworld.c 文件转换为 Web 程序集。目前,我正在尝试使用 emscripten 将 python 转换为 Web 程序集。问题是 emscripten 目前不支持 python,因此作为一种解决方法,我尝试使用 Cython 将 python 代码转换为 C,我成功地做到了。尽管尝试将 cython c 文件转换为 Web 程序集时出现错误。这是控制台日志:
$emcc pony_gp.c -o pony_gp.html
In file included from pony_gp.c:11:
In file included from /usr/include/python2.7/Python.h:58:
/usr/include/python2.7/pyport.h:886:2: error: "LONG_BIT definition appears
wrong for platform (bad gcc/glibc config?)."
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
根据 pyport.h,产生这个错误是因为在一些 32 位系统中,LONG_BIT 被错误地定义为 64 而应该是 32。我尝试注释掉这一行,但这只允许程序静默运行,在最终没有产生任何网络汇编代码,只有 html 和 javascript。
我已阅读here,该问题是因为“cmake 正在选择一个版本的 python dylib 和一个单独的 python 版本作为标题”。这是有道理的,因为我最近从 Python 2.7.13-1 降级到 Python 2.7.11-1,因为 Python 2.7.13-1 与 python-dev 包不兼容。不过,我不知道如何解决这个问题。
有人知道该怎么做吗?
【问题讨论】:
-
如果您发布 python 代码和将其转换为 cython 的步骤将会很有帮助。这会增加你得到答案的机会。
标签: python c emscripten webassembly cythonize