Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Emscripten to Windows releases #7484

Open
ofTheo opened this issue Apr 11, 2023 · 11 comments
Open

Add Emscripten to Windows releases #7484

ofTheo opened this issue Apr 11, 2023 · 11 comments
Milestone

Comments

@ofTheo
Copy link
Member

ofTheo commented Apr 11, 2023

Not sure if it works with Visual Studio compiler, but we should at least try it with msys2 / mingw64

relevant thread:
https://forum.openframeworks.cc/t/webview-of-integration-how-to-dispatch/40464/16

@ofTheo ofTheo added this to the 0.12.0 milestone Apr 11, 2023
@ofTheo ofTheo mentioned this issue Apr 11, 2023
77 tasks
ofTheo added a commit to ofTheo/openFrameworks that referenced this issue Apr 18, 2023
@ofTheo ofTheo closed this as completed in f028d48 Apr 18, 2023
dimitre pushed a commit to dimitre/openFrameworks that referenced this issue Apr 19, 2023
* update pg submodule

* add emscripten to vs and msys2 packages - closes openframeworks#7484

* pg master
@ofTheo ofTheo reopened this Apr 21, 2023
@ofTheo
Copy link
Member Author

ofTheo commented Apr 21, 2023

tried with the latest mingw64 msys2 nightly now that the emscripten libs are there

In the mingw64 shell these steps worked:

# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git

# Enter that directory
cd emsdk

# Download and install the latest SDK tools.
./emsdk install latest

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

# needed for mingw64 - NOTE: the other two env files don't work 
./emsdk activate latest --permanent

Then when I try and make an example with:
emmake make

I get an error showing that the CXX is being set to the emscripten c++ path without the forward slashes.

ie: it is showing like:
CUserstheoemsdkupstreamemscriptenem++.bat

instead of:
/C/Users/theo/emsdk/upstream/emscripten/em++.bat

Not sure if it is our make files that is passing the CXX like that or emmake.
I think it will work if we can get the CXX compiler path set.

cc @oxillo

@ofTheo
Copy link
Member Author

ofTheo commented Apr 21, 2023

hmm looking at this issue seems to imply that on mingw64 you need to call a different make command:
emscripten-core/emscripten#2005

emmake mingw64-make

@Jonathhhan
Copy link
Contributor

@ofTheo with make I get the same error. with mingw32-make i get this error:

make: C:\msys64\mingw64\bin\mingw32-make.exe
Compiling OF library for Release
mingw32-make[1]: Entering directory 'C:/Users/Jonat/Desktop/of_v20230427_vs_release/libs/openFrameworksCompiled/project'
/usr/bin/sh: -c: line 2: syntax error: unexpected end of file
mingw32-make[2]: *** [makefileCommon/compile.core.mk:233: C:/Users/Jonat/Desktop/of_v20230427_vs_release/libs/openFrameworksCompiled/lib/emscripten/obj/Release/.compiler_flags] Error 2
mingw32-make[1]: *** [makefileCommon/compile.core.mk:204: Release] Error 2
mingw32-make[1]: Leaving directory 'C:/Users/Jonat/Desktop/of_v20230427_vs_release/libs/openFrameworksCompiled/project'
mingw32-make: *** [C:/Users/Jonat/Desktop/of_v20230427_vs_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:125: Release] Error 2
emmake: error: 'C:\msys64\mingw64\bin\mingw32-make.exe' failed (returned 2)

@Jonathhhan
Copy link
Contributor

@ofTheo I got Emscripten running on Windows with the wsl Linux subsystem.
I followed this description: https://www.codeproject.com/Articles/5160967/Bring-Your-Cplusplus-Code-to-the-Web

@ofTheo
Copy link
Member Author

ofTheo commented Aug 9, 2023

@Jonathhhan did you use the mingw OF nightly to do it?
is it possible to document exactly what additional steps you had to do ?

We could then add it to the setup guide.

Thanks so much!
Theo

@Jonathhhan
Copy link
Contributor

Jonathhhan commented Aug 9, 2023

@ofTheo I used the linux64gcc6 nightly.

This is what I did (partly copied from https://www.codeproject.com/Articles/5160967/Bring-Your-Cplusplus-Code-to-the-Web):

Before we can install Ubuntu from Microsoft, we must first enable Developer's mode and WSL. To enable Developer mode, head to Settings > Update & Security > For Developers and select “Developer mode”.

Next, WSL has to be enabled on Windows Features. In the Windows searchbar, type "Turn Windows Features On or Off" and select that option. Scroll all the way down and check the "Windows Subsystem For Linux" option.

Next, launch Microsoft Store by clicking its button on the taskbar. Search for "Ubuntu" and click "Install" on the Ubuntu 22.04 in the search result. It takes about 5 minutes.

Start wsl in the terminal and add a Ubuntu user.

sudo apt update
sudo apt upgrade
git clone https://github.com/emscripten-core/emsdk.git

change to the newly cloned emsdk directory.

cd emsdk

Download and install the latest SDK tools.

./emsdk install latest

Set up the compiler configuration to point to the "latest" SDK.

./emsdk activate latest

Activate PATH and other environment variables in the current terminal

source ./emsdk_env.sh

install make

sudo apt install make

install chrome

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

for make (optional)

sudo apt-get install pkg-config
sudo apt-get install gcc
cd /mnt/c/Users/Jonat/Downloads/of_v20230809_linux64gcc6_release/scripts/linux/ubuntu (your own path)
sudo bash install_dependencies.sh

@ofTheo
Copy link
Member Author

ofTheo commented Aug 10, 2023

Thanks @Jonathhhan
Ahh I see you end up essentially using the ubuntu OF release to run emscripten.

I was hoping it would enable it via the windows OF downloads :)

@danzeeeman
Copy link
Member

I found this https://github.com/nokotan/VSExtForEmscripten worth checking out.

also note the official website says to install linux on your windows box to compile things
image

@Jonathhhan
Copy link
Contributor

@danzeeeman I can confirm that it works well with windows subsystem for windows.

@danzeeeman
Copy link
Member

@ofTheo if we can configure the VS project for emscripten build it should work with that extension

@oxillo
Copy link
Contributor

oxillo commented Sep 16, 2023

On MSYS2, I've managed to go to the linker step following the instructions :

  1. launch a UCRT64 shell (not a MINGW64 !)
  2. Install emscripten with pacman -Sy mingw-w64-ucrt-x86_64-emscripten
  3. Close and restart the UCRT64 shell
  4. Download emscripten 3rdparty libraries with $OF_ROOT\script\emscripten\download_libs.sh
  5. Run emmake make...

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

No branches or pull requests

5 participants