apramc
apramc

Reputation: 1386

clang: 'No available targets are compatible with this triple

I built clang from source, and I trying to compile a hello_world code that I get the following error.

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

  1. clang version 6.0.0 (trunk 315722)
  2. Target: x86_64-unknown-linux-gnu
  3. Thread model: posix
  4. InstalledDir: /opt/apps/clang/bin

code is as below:

#include <iostream>

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

I tried, clang++ -std=c++11 hello.cpp -o run and clang++ -std=c++11 -target x86_64-unknown-linux-gnu hello.cpp -o run

Upvotes: 2

Views: 4726

Answers (1)

bandito40
bandito40

Reputation: 637

I just started using emscripten and ran into the same problem. I am running on Linux (Ubuntu) and did install from git. So I attempted updating.

First I tried this command: /emsdk update which spit out this message:

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

this case, use "git pull" instead of "emsdk update" to update emsdk. (Not doing that automatically in case you have local changes) Alternatively, use "emsdk update-tags" to refresh the latest list of tags from the different Git repositories.

So did the ./emsdk update-tags which spit out:

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

Then I ran ./emsdk install latest which spit out:

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'.

Then I ran the command ./emsdk activate latest which spit out:

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

As you can see it says in the bold/italic text to update your path so I did that with source ./emsdk_env.sh which spit out:

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

My program complies fine now.

This also fixed this error:

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

And the emcc version got updated from 1.22 to 1.37.37

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.37 clang version 5.0.0 (emscripten 1.37.37 : 1.37.37)

Upvotes: 0

Related Questions