gpt4 book ai didi

c++ - clang : 'No available targets are compatible with this triple

转载 作者:太空宇宙 更新时间:2023-11-04 12:55:48 24 4
gpt4 key购买 nike

我从源代码构建 clang,并尝试编译 hello_world 代码,但出现以下错误。

unable to create target: 'No available targets are compatible with this triple.

  1. clang 版本 6.0.0(主干 315722)
  2. 目标:x86_64-unknown-linux-gnu
  3. 线程模型:posix
  4. 安装目录:/opt/apps/clang/bin

代码如下:

#include <iostream>

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

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

最佳答案

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

首先我尝试了这个命令:/emsdk update 输出了这条消息:

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

在这种情况下,使用“git pull”而不是“emsdk update”来更新emsdk。 (如果您有本地更改,则不会自动执行此操作)或者,使用“emsdk update-tags”刷新来自不同 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-like replacement + linker emulating GNU ld) 1.37.37clang version 5.0.0 (emscripten 1.37.37 : 1.37.37)

关于c++ - clang : 'No available targets are compatible with this triple,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46778183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com