emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

emcc command not found

Open caperavensoftware opened this issue 9 years ago • 35 comments

Having a hell of a time getting emcc working on mac. Having followed and ensured that all the requirements are installed, i can't seem to get emcc to run outside of the installed folder getting a command not found.

Are these steps correct? http://webassembly.org/getting-started/developers-guide/

caperavensoftware avatar Oct 22 '17 18:10 caperavensoftware

Hi, if you're inside emsdk folder please type:

source ./emsdk_env.sh
emcc --version

What output do you see?

trzecieu avatar Oct 22 '17 19:10 trzecieu

source:

Adding directories to PATH:
PATH += /Users/username/Documents/GitHub/webassembly/emsdk
PATH += /Users/username/Documents/GitHub/webassembly/emsdk/clang/e1.37.22_64bit
PATH += /Users/username/Documents/GitHub/webassembly/emsdk/node/4.1.1_64bit/bin
PATH += /Users/username/Documents/GitHub/webassembly/emsdk/emscripten/1.37.22

Setting environment variables:
EMSDK = /Users/username/Documents/GitHub/webassembly/emsdk
EM_CONFIG = /Users/username/.emscripten
BINARYEN_ROOT = /Users/username/Documents/GitHub/webassembly/emsdk/clang/e1.37.22_64bit/binaryen
EMSCRIPTEN = /Users/username/Documents/GitHub/webassembly/emsdk/emscripten/1.37.22

for the version I get this

emcc (Emscripten gcc/clang-like replacement) 1.37.22 (commit 024e3bb3b4d1860c46c2c887aad868db7053fe1a)
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.

when I do emcc -v outside that folder I get this

-bash: emcc: command not found

caperavensoftware avatar Oct 23 '17 05:10 caperavensoftware

You always have to source ./emsdk_env.sh first in a new terminal session

gogoprog avatar Oct 23 '17 08:10 gogoprog

ok, that makes sense now, ty

caperavensoftware avatar Oct 23 '17 08:10 caperavensoftware

@gogoprog why do we need to that all the time in a new terminal session? it is so boring.

hon avatar Oct 23 '17 08:10 hon

@hon because there is nothing set magically: your default PATH doesn't contain the emcc path so it has to be set.

But of course you can set that up once for all by automatically calling the source ./emsdk_env.sh in your session startup script. Look for .bashrc configuration if you're using bash (I guess that's the case on OsX)

gogoprog avatar Oct 23 '17 08:10 gogoprog

@gogoprog does't source ./emsdk_env.sh set env path?

which emcc
/Users/hon/work/emsdk-portable/emscripten/incoming/emcc

and the '/Users/hon/work/emsdk-portable/emscripten/incoming/emcc' is already set into $PATH (in .zshrc file)

but it does't work...

hon avatar Oct 23 '17 10:10 hon

PATH contains directories instead of file paths. After source ./emsdk_env.sh type echo $PATH to see how it's populated.

trzecieu avatar Oct 23 '17 10:10 trzecieu

@hon yes source ./emsdk_env.sh will set the PATH.

How is it set in your .zshrc file?

gogoprog avatar Oct 23 '17 11:10 gogoprog

@gogoprog

➜  emsdk-portable echo $PATH
./node_modules/.bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/hon/work/go/bin:/usr/local/go/bin:/usr/local/nginx/sbin:/Users/hon/.cargo/bin:/Users/hon/Library/Android/sdk/build-tools/23.0.1:/Users/hon/rust/src:/Users/hon/Library/Android/sdk/tools:/Users/hon/Library/Android/sdk/platform-tools:/usr/local/bin:/usr/include/libxml2/:/Users/hon/work/emsdk-portable:/Users/hon/work/emsdk-portable/clang/fastcomp/build_incoming_64/bin:/User/hon/work/emsdk-portable/emscripten/incoming:/Users/hon/work/emsdk-portable/emscripten/incoming/emcc
➜  emsdk-portable emcc
zsh: command not found: emcc
➜  emsdk-portable

the binary file is set in $PATH, but can not work.

hon avatar Oct 24 '17 01:10 hon

@hon You should add /Users/hon/work/emsdk-portable/emscripten/incoming/ to the PATH as a folder what contains emcc, not a full path to emcc.

trzecieu avatar Oct 24 '17 06:10 trzecieu

Also you better just do the following in your .zshrc:

pushd path/to/emsdk
source ./emsdk_env.sh
popd

So the PATH will be correctly set

gogoprog avatar Oct 24 '17 07:10 gogoprog

@asRIA folder /Users/hon/work/emsdk-portable/emscripten/incoming/ is alreay in $PATH @gogoprog I add the commands, but I need to type the following command in every new session:

. ~/.zshrc

what I wondering now is: the function of env path is make some binary file can be executed everywhere in the system, with out type the full path. since the path was in the $PATH, why can't it be executed? Sorry for so many questions. I never met the situation before(I have to source .sh file every time to make some command work).

hon avatar Oct 24 '17 08:10 hon

Maybe you don't use ZSH, but the regular bash? Can you type ps -p $$ and check the output? If it's a bash, then it's needed to change .bashrc file

trzecieu avatar Oct 24 '17 08:10 trzecieu

@asRIA

➜  emscripten ps -p $$
  PID TTY           TIME CMD
33664 ttys001    0:00.58 -zsh

hon avatar Oct 24 '17 08:10 hon

Hm.. Interesting. Last call: in .zshrc please just leave:

. /Users/hon/work/emsdk-portable/emsdk_env.sh

trzecieu avatar Oct 24 '17 08:10 trzecieu

Now it works, but every time in a new session, the console outputs:

Last login: Tue Oct 24 17:03:49 on ttys004
~/work/emsdk-portable ~
Adding directories to PATH:
PATH += /Users/hon/work/emsdk-portable/node/4.1.1_64bit/bin
PATH += /Users/hon/work/emsdk-portable/emscripten/incoming

Setting environment variables:
EMSDK = /Users/hon/work/emsdk-portable
EM_CONFIG = /Users/hon/.emscripten
EMSCRIPTEN = /Users/hon/work/emsdk-portable/emscripten/incoming

/Users/hon/.zshrc:popd:151: directory stack empty
➜  ~

hon avatar Oct 24 '17 09:10 hon

If you use the absolute path and . the popd and pushd commands aren't needed.

trzecieu avatar Oct 24 '17 09:10 trzecieu

ok, ty~

hon avatar Oct 24 '17 09:10 hon

I have same issue, did everything but not able to fix it tonight.

sfjadi2010 avatar Jul 20 '18 02:07 sfjadi2010