在Ubuntu 16.10上将C程序编译为WebAssembly程序,出现“错误:没有可用的目标与此三元组兼容”

Cas*_*per 5 c ubuntu emscripten webassembly

在学习完本教程之后,我尝试使用以下命令将C程序编译为WebAssembly。

emcc hello.c -s WASM=1 -o hello.html
Run Code Online (Sandbox Code Playgroud)

但是我遇到了“ No available targets are compatible with this triple.”问题。

$ emcc hello.c -s WASM=1 -o hello.html
WARNING  root: LLVM version appears incorrect (seeing "(https://github.com/kripken/emscripten-fastcomp-clang/", expected "3.4")
INFO     root: (Emscripten: Running sanity checks)
WARNING  root: Assigning a non-existent settings attribute "WASM"
WARNING  root:  - did you mean one of ASM_JS?
WARNING  root:  - perhaps a typo in emcc's  -s X=Y  notation?
WARNING  root:  - (see src/settings.js for valid values)
/home/casper/Desktop/test/emsdk/clang/fastcomp/build_incoming_64/bin/lli: error creating EE: No available targets are compatible with this triple.
FAIL: Running the generated program failed!
Run Code Online (Sandbox Code Playgroud)

怎么解决呢?



EMCC版本

$ emcc --version
emcc (Emscripten GCC-like replacement) 1.22.1 ()
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Run Code Online (Sandbox Code Playgroud)


基本信息

OS           : Ubuntu 16.10
emcc Location: /usr/bin/emcc
Run Code Online (Sandbox Code Playgroud)


JF *_*ien 3

您正在运行emcc版本 1.22.1,该版本可以追溯到 8/7/2014,在 WebAssembly 启动之前。

emsdk在您遵循的指令中,您必须安装了最新的 emscripten 版本(这就是sdk-incoming-64bit这些指令的作用:incoming是最新的分支),但在您的系统中发现了较旧的 emscripten。

跑步:

which emcc
echo $PATH
Run Code Online (Sandbox Code Playgroud)

他们说什么?我怀疑你那里有一份旧的铭文。您可能还想检查和/或删除您的~/.emscripten文件,该文件也可能包含过时的信息。

您可以更改路径、删除较旧的 emscripten,或使用其绝对路径调用 SDK 的 emscripten(尽管如果其他脚本沿路径选择较旧的版本,这可能会失败)。

不要忘记(根据教程的说明)激活您已安装的 SDK:

./emsdk activate --build=Release sdk-incoming-64bit binaryen-master-64bit
Run Code Online (Sandbox Code Playgroud)

并运行:

source ./emsdk_env.sh
Run Code Online (Sandbox Code Playgroud)

最后一个命令需要为每个 shell 会话运行。如果你打开一个新的shell,你需要重新安装sourceSDK。