emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 662 forks source link

`emcmake cmake . -G "MSYS Makefiles"` returns an error #1314

Closed vault-thirteen closed 7 months ago

vault-thirteen commented 7 months ago

I am trying to use the emcmake tool in MSYS2 on Windows.

I have set environment variables of Emscripten and checked that they are really set.

$ echo $PATH
/ucrt64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

$ export PATH=${PATH}:/d/Temp/1/emsdk:/d/Temp/1/emsdk/node/16.20.0_64bit/bin:/d/Temp/1/emsdk/upstream/emscripten:/d/Temp/1/emsdk/python/3.9.2-nuget_64bit

$ echo $PATH
/ucrt64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/d/Temp/1/emsdk:/d/Temp/1/emsdk/node/16.20.0_64bit/bin:/d/Temp/1/emsdk/upstream/emscripten:/d/Temp/1/emsdk/python/3.9.2-nuget_64bit

I am using the MSYS Makefiles generator for CMake while it seems quite logical for me to use MSYS in the MSYS terminal.

$ emcmake cmake . -G "MSYS Makefiles"
configure: cmake . -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=D:\Temp\1\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten
.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=D:/Temp/1/emsdk/node/16.20.0_64bit/bin/node.exe
emcmake: error: 'cmake . -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=D:\Temp\1\emsdk\upstream\emscripten\cmake\Modules\Platform\Emsc
ripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=D:/Temp/1/emsdk/node/16.20.0_64bit/bin/node.exe' failed: [WinError 2] The system canno
t find the file specified

I do not understand which file is not found. I have added Python's and NodeJj's executable files to the PATH environment variable.

Thank you.

vault-thirteen commented 7 months ago

The solution is to run this command in the native Windows Command Prompt. By the way I have found a bug in your activator. The activator does not add path of Python compiler to the PATH environment variable.

sbc100 commented 7 months ago

The soltion is to run this command in the native Windows Command Prompt. By the way I have found a bug in your activator. The activator does not add path of Python compiler to the PATH environment variable.

IIUC this is not a bug but a feature. We set EMSDK_PYTHON so that emcc.bat and other scripts can find the right python to use, but we don't want to inject out python into the users PATH, since that might interfere with any existing python installation they have.

sbc100 commented 7 months ago

The soltion is to run this command in the native Windows Command Prompt.

If you would like to try to make emsdk work in the msys shell any patches would be most welcome.

Does . emsdk_env.sh work in the msys shell?

vault-thirteen commented 7 months ago

It is quite difficult to check all this. I do not know what it means but it returns an error: ./emsdk: line 46: exec: python: cannot execute: Is a directory

 UCRT64 /d/Temp/1/emsdk
$ ./emsdk_env.sh
./emsdk: line 46: exec: python: cannot execute: Is a directory
sbc100 commented 7 months ago

Sorry, I accidentally edited your comment above rather than replying to. I will attempt to restore if I can.

sbc100 commented 7 months ago

It is quite difficult to check all this. I do not know what it means but it returns an error: ./emsdk: line 46: exec: python: cannot execute: Is a directory

To run emsdk you do first need to have a version of python.exe in your PATH. I can't remember if its better to use the MSYS version of python here or the normal windows version. As you can probably tell we don't have many msys users or much testing of this environment. If you have access to an MSYS environment and would like to help improve our support that would most welcome.

 UCRT64 /d/Temp/1/emsdk
$ ./emsdk_env.sh
./emsdk: line 46: exec: python: cannot execute: Is a directory

Because emsdk_env.sh should not be executed directly (indeed it should not be marked as executable), but run with the . or source operator. e.g. . emsdk_env.sh or source emsdk_env.sh. This allows it to modify the currently current shell environment.