Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

emcc command not found #5696

Closed
caperavensoftware opened this issue Oct 22, 2017 · 35 comments
Closed

emcc command not found #5696

caperavensoftware opened this issue Oct 22, 2017 · 35 comments

Comments

@caperavensoftware
Copy link

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/

@trzecieu
Copy link
Contributor

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

source ./emsdk_env.sh
emcc --version

What output do you see?

@caperavensoftware
Copy link
Author

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

@gogoprog
Copy link
Contributor

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

@caperavensoftware
Copy link
Author

ok, that makes sense now, ty

@hon
Copy link

hon commented Oct 23, 2017

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

@gogoprog
Copy link
Contributor

gogoprog commented Oct 23, 2017

@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)

@hon
Copy link

hon commented Oct 23, 2017

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

@trzecieu
Copy link
Contributor

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

@gogoprog
Copy link
Contributor

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

How is it set in your .zshrc file?

@hon
Copy link

hon commented Oct 24, 2017

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

@trzecieu
Copy link
Contributor

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

@gogoprog
Copy link
Contributor

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

@hon
Copy link

hon commented Oct 24, 2017

@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).

@trzecieu
Copy link
Contributor

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

@hon
Copy link

hon commented Oct 24, 2017

@asria

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

@trzecieu
Copy link
Contributor

trzecieu commented Oct 24, 2017

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

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

@hon
Copy link

hon commented Oct 24, 2017

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
➜  ~

@trzecieu
Copy link
Contributor

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

@hon
Copy link

hon commented Oct 24, 2017

ok, ty~

@sfjadi2010
Copy link

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

@posthighline
Copy link

I have the same issue too. I followed this guide perfectly, it seems like it's incomplete:
https://webassembly.org/getting-started/developers-guide/

@kripken
Copy link
Member

kripken commented Jul 23, 2018

Is the issue that source ./emsdk_env.sh needs to be run after install and activate? That does seem to be missing on the webassembly.org instructions (but is present on the emscripten docs).

If that's it, I can open a PR to update their docs, but please let me know if that is indeed what's wrong.

@sfjadi2010
Copy link

sfjadi2010 commented Jul 23, 2018

@kripken I tried emscripten docs too, but it seems not working.

@kripken
Copy link
Member

kripken commented Jul 23, 2018

That's strange.

To see if it's not something with how the PATH is set up, you can call emcc directly, without assuming it is in your path. If you are in the emsdk dir, you can find it with something like

$ find -name emcc.py
./emscripten/1.38.1/emcc.py

And can then run it with copying that last line, in this example, ./emscripten/1.38.1/emcc.py

@Samuelfaure
Copy link

Samuelfaure commented Sep 13, 2018

For anyone having issues :
If you moved your emsdk folder after you ran ./emsdk activate --build=Release sdk-incoming-64bit binaryen-master-64bit the sourcing wont work and you need to rerun this command.

@kmturley
Copy link

kmturley commented Oct 17, 2018

I solved by adding this line to my .bash_profile file:

# Web Assembly paths
source "/Users/${USER}/Sites/emsdk/emsdk_env.sh"

@eyworldwide
Copy link

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
➜  ~

You need not to see these ugly logs every time when open a bash.

The issue is because the command source ./emsdk_env.sh export path failed. I digged into the shell code but I could not fix it. However, I can add the path to the .profile file (which is in your user directory of the system) manually:

  1. open the emsdk_set_env.sh with any text editor, copy the first line of the code, for me, it is:

    export PATH="/Users......Frameworks/Mono.framework/Versions/Current/Commands"

  2. open '~/.profile', then paste the code:

    export PATH="/Users......Frameworks/Mono.framework/Versions/Current/Commands:${PATH}

Be careful, add :${PATH} in the end. Because we only want to add path other than cover the global paths.

@eliottparis
Copy link

eliottparis commented Jun 29, 2019

Adding this to .zshrc/.bash_profile did the trick for me on macOS (set the emcc paths for new terminal sessions and hiding output logs):

source ~/path-to-emsdk/emsdk_env.sh &> /dev/null

@Ayan-web
Copy link

add
source ./emsdk_env.sh
to .bashrc or zshrc file

@cool-delete
Copy link

cool-delete commented Aug 4, 2021

Until now, I found the issue
source ./emsdk_env.sh
echo ${EMSDK}
get ""

image

@joshxyzhimself
Copy link

what worked in my case, is just login as root

# login as root
sudo -s

# deps
apt install python3
apt install cmake

# prep emsdk
git clone git@github.com:emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ../

# compile example-project
mkdir example-project
cd example-project
emcmake cmake ../some-wasm-wrapper-dir/
cmake --build ./

@tsavo-at-pieces
Copy link

Just a heads up for peeps. Installed via brew https://formulae.brew.sh/formula/emscripten#default and it all worked great out of the box. Worth a shot!

@KangChou
Copy link

emcc --version

emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.21 (f9e8147)
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.

@LakshmiMounika29
Copy link

source ./emsdk_env.sh
emcc --version

instead of using this try for windows
cd WHERE/YOU/INSTALLED/EMSCRIPTEN
emsdk update
emsdk install latest
emsdk activate latest
emsdk_env.bat
emcmdprompt.bat

@shubham0204
Copy link

In my case, I had not used the activate command, which resulted in a bash: command not found even after setting the environment variables in .bashrc,

# Make the "latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate latest

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests