我是emscripten的新手;几天前我下载它只是为了尝试为JS制作一个游戏端口。
无论如何,经过一些步骤,我现在遇到这个问题(在Ubuntu 16.04 STL上)。
通过遵循构建步骤here,首先,我已经设置了环境变量
NuGetFallbackFolder
然后我尝试在项目目录中使用source ./emsdk_env.sh
配置项目。在检查emscripten需要的工具时,我遇到了这个错误:
emconfigure ./configure
所以我尝试使用以下命令设置该变量:
checking for SDL... no
configure: error: Package requirements (sdl2 >= 2.0.1) were not met:
No package 'sdl2' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SDL_CFLAGS
and SDL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
ERROR:root:Configure step failed with non-zero return code 1! Command line: ['./configure'] at ...
这是我的机器上实际上export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/
的位置,但它没有帮助。
然后我设置了sdl2.pc
所需的以下变量:
emconfigure
并重新启动已成功完成的export SDL_PATH=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
export SDL_LIBS=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
export SDL_CFLAGS=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
export SDLNET_LIBS=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
export SDLNET_CFLAGS=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
export SDLMIXER_LIBS=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
export SDLMIXER_CFLAGS=/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h
。
所以下一步是emconfigure ./configure
,它给了我以下错误:
emmake make
这意味着,我认为,make all-recursive
make[1]: Entering directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0'
Making all in textscreen
make[2]: Entering directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0/textscreen'
Making all in fonts
make[3]: Entering directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0/textscreen/fonts'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0/textscreen/fonts'
Making all in .
make[3]: Entering directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0/textscreen'
CC txt_conditional.o
Traceback (most recent call last):
File "/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/emcc", line 11, in <module>
python_selector.run(__file__)
File "/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/tools/python_selector.py", line 38, in run
sys.exit(run_by_import(filename, main) if on_allowed_version() else run_by_subprocess(filename))
File "/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/tools/python_selector.py", line 13, in run_by_import
return getattr(importlib.import_module(os.path.basename(filename)), main)()
File "/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/emcc.py", line 1345, in run
assert header.endswith(HEADER_ENDINGS), 'if you have one header input, we assume you want to precompile headers, and cannot have source files or other inputs as well: ' + str(headers) + ' : ' + header
AssertionError: if you have one header input, we assume you want to precompile headers, and cannot have source files or other inputs as well: ['/home/ustym/Documents/Projects/emsdk/emscripten/1.37.38/system/include/SDL/SDL.h', 'txt_conditional.c'] : txt_conditional.c
Makefile:447: recipe for target 'txt_conditional.o' failed
make[3]: *** [txt_conditional.o] Error 1
make[3]: Leaving directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0/textscreen'
Makefile:467: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0/textscreen'
Makefile:585: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ustym/Documents/Projects/chocolate-doom-3.0.0'
Makefile:438: recipe for target 'all' failed
make: *** [all] Error 2
,SDL_PATH
,SDL_LIBS
...变量未正确设置。或者我可能只需要在SDL目录中预编译这些头文件。
最后一件事:如果我跳过设置SDL变量和配置步骤并刚刚启动SDL_CFLAGS
,编译进展顺利,但是,emmake make
命令给了我
emcc
对于所有生成的WARNING:root: .o is not valid LLVM bitcode
个文件。这实际上是有道理的。
所以我很困惑。有人可以告诉我如何为emscripten正确设置.o
,或者我是否真的需要在SDL目录中预编译这些头文件?谢谢!
答案 0 :(得分:0)
首先,设置PKG_CONFIG_PATH
,包括或者更糟糕的是,将库目录(-I
和-L
)包含到主机库中。对我来说看起来很糟糕:Emscripten对象文件包含LLVM bitcode(而不是主机代码),其.so
文件AFAIK也包含bitcode。这是bitcode被转换为JS,而不是主机代码。因此,您需要自己构建程序与Emscripten的依赖关系(并且很可能不应该将它们安装到主机系统)。幸运的是,有一些官方的 Emscripten端口(参见here)了解详情。
Emscripten有自己的SDL v1实现(您可能尝试手动使用),但您的程序似乎需要SDL2。好消息:您可能只需要在-s USE_SDL=2
时将CFLAGS
传递给LDFLAGS
和configure
(有关SDL2端口的信息,请参阅上面的链接)。坏消息:有些东西可能没有完全移植。但我在某种程度上成功地使用了它。
当您在主机上configure
d并使用emmake
时,您可能在emconfigure
和emmake
调整的其他参数中已经编译了路径,而./configure
已经通过{ {1}}不受emconfigure
控制,因此主机gcc
/ clang
只生成了机器代码。