叮叮当当:"没有可用的目标与这三重兼容

clang: 'No available targets are compatible with this triple

本文关键字:三重 目标 叮叮当当      更新时间:2023-10-16

我从源代码构建了clang,并试图编译hello_world代码,但我得到了以下错误。

无法创建目标:'没有可用的目标与兼容这三个。

  1. clang 6.0.0版(trunk 315722)
  2. 目标:x86_64-unknown-linux-gnu
  3. 螺纹型号:posix
  4. InstalledDir:/opt/apps/crang/bin

代码如下:

#include <iostream>
int main()
{
int a = 1;
std::cout << a << std::endl;
return 0;
}

我试过了,clang++-std=c++11hello.cpp-o运行和clang++-std=c++11-target x86_64-unknown-linux-gnu hello.cpp-o运行

我刚开始使用emscripten,遇到了同样的问题。我在Linux(Ubuntu)上运行,确实是从git安装的。所以我尝试更新。

首先我尝试了这个命令:/emsdk update,它吐出了这个消息:

You seem to have bootstrapped Emscripten SDK by cloning from GitHub. In 

在这种情况下,使用";git pull";而不是";emsdk更新";更新emsdk。(如果您有本地更改,则不会自动执行此操作)或者,使用";emsdk更新标签";以刷新来自不同Git存储库的最新标签列表。

吐出的./emsdk update-tags也是如此

Fetching all tags from Emscripten Github repository...
Done. 124 tagged releases available, latest is 1.37.37.
Fetching all tags from Binaryen Github repository...
Done. 51 tagged Binaryen releases available, latest is 1.37.37.
Fetching all precompiled tagged releases..
Downloading: /home/usr/program/emsdk/llvm-tags-32bit.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/tag/linux_32bit/index.txt
Downloading: /home/usr/program/emsdk/llvm-tags-64bit.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/tag/linux_64bit/index.txt, 1269 Bytes

然后我运行./emsdk install latest,它吐出:

Installing SDK 'sdk-1.37.37-64bit'..
Installing tool 'clang-e1.37.37-64bit'..
The contents of file 'llvm/tag/linux_64bit/emscripten-llvm-e1.37.37.tar.gz' already exist in destination '/home/usr/program/emsdk/clang/e1.37.37_64bit', skipping.
Done installing tool 'clang-e1.37.37-64bit'.
Installing tool 'node-8.9.1-64bit'..
The contents of file 'node-v8.9.1-linux-x64.tar.xz' already exist in destination '/home/usr/program/emsdk/node/8.9.1_64bit', skipping.
Done installing tool 'node-8.9.1-64bit'.
Installing tool 'emscripten-1.37.37'..
The contents of file 'https://github.com/kripken/emscripten/archive/1.37.37.tar.gz' already exist in destination '/home/usr/program/emsdk/emscripten/1.37.37', skipping.
Done installing tool 'emscripten-1.37.37'.
Done installing SDK 'sdk-1.37.37-64bit'.

然后我运行命令./emsdk activate latest,它吐出:

Writing .emscripten configuration file to user home directory /home/bandito/
The Emscripten configuration file /home/bandito/.emscripten has been rewritten with the following contents:
import os
LLVM_ROOT='/home/usr/program/emsdk/clang/e1.37.37_64bit'
EMSCRIPTEN_NATIVE_OPTIMIZER='/home/usr/program/emsdk/clang/e1.37.37_64bit/optimizer'
BINARYEN_ROOT='/home/usr/program/emsdk/clang/e1.37.37_64bit/binaryen'
NODE_JS='/home/usr/program/emsdk/node/8.9.1_64bit/bin/node'
EMSCRIPTEN_ROOT='/home/usr/program/emsdk/emscripten/1.37.37'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
***To conveniently access the selected set of tools from the command line, consider adding the following directories to PATH, or call 'source ./emsdk_env.sh' to do this for you.***   /home/usr/program/emsdk:/home/usr/program/emsdk/clang/e1.37.37_64bit:/home/usr/program/emsdk/node/8.9.1_64bit/bin:/home/usr/program/emsdk/emscripten/1.37.37
Set the following tools as active:
clang-e1.37.37-64bit
node-8.9.1-64bit
emscripten-1.37.37

正如你所看到的,它在粗体/斜体文本中说要更新你的路径,所以我用source ./emsdk_env.sh这样做了,它吐出:

Adding directories to PATH:
PATH += /home/usr/program/emsdk
PATH += /home/usr/program/emsdk/clang/e1.37.37_64bit
PATH += /home/usr/program/emsdk/node/8.9.1_64bit/bin
PATH += /home/usr/program/emsdk/emscripten/1.37.37
Setting environment variables:
EMSDK = /home/usr/program/emsdk
EM_CONFIG = /home/bandito/.emscripten
BINARYEN_ROOT = /home/usr/program/emsdk/clang/e1.37.37_64bit/binaryen
EMSCRIPTEN = /home/usr/program/emsdk/emscripten/1.37.37

我的程序现在运行良好。

这也修复了这个错误:

WARNING  root: LLVM version appears incorrect (seeing "", expected "3.4")

emcc版本从1.22更新为1.37.37

emcc(类似Emscripten gcc/clang的替换+模拟GNU ld的链接器)1.37.37clang 5.0.0版(emscripten 1.37.37:1.37.37)