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/
Hi, if you're inside emsdk folder please type:
source ./emsdk_env.sh
emcc --version
What output do you see?
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
You always have to source ./emsdk_env.sh first in a new terminal session
ok, that makes sense now, ty
@gogoprog why do we need to that all the time in a new terminal session? it is so boring.
@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 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...
PATH contains directories instead of file paths.
After source ./emsdk_env.sh type echo $PATH to see how it's populated.
@hon yes source ./emsdk_env.sh will set the PATH.
How is it set in your .zshrc file?
@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 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.
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
@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).
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
@asRIA
➜ emscripten ps -p $$
PID TTY TIME CMD
33664 ttys001 0:00.58 -zsh
Hm.. Interesting. Last call: in .zshrc please just leave:
. /Users/hon/work/emsdk-portable/emsdk_env.sh
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
➜ ~
If you use the absolute path and . the popd and pushd commands aren't needed.
ok, ty~
I have same issue, did everything but not able to fix it tonight.
I have the same issue too. I followed this guide perfectly, it seems like it's incomplete:
https://webassembly.org/getting-started/developers-guide/
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.
@kripken I tried emscripten docs too, but it seems not working.
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
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.
I solved by adding this line to my .bash_profile file:
# Web Assembly paths
source "/Users/${USER}/Sites/emsdk/emsdk_env.sh"
Now it works, but every time in a new session, the console outputs:
```shell
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/incomingSetting 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:
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"
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.
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
Most helpful comment
You always have to
source ./emsdk_env.shfirst in a new terminal session