[Help] Compiling OR-Tools to WebAssembly with Emscripten

139 views
Skip to first unread message

Sebastián José

unread,
May 2, 2025, 6:38:20 PM5/2/25
to or-tools-discuss
I’ve been trying for a long time to compile Google OR-Tools to WebAssembly using Emscripten. I’d love to be able to run simple optimization models in the browser, but the task seems impossible—every time I try, the build fails for one reason or another. Could someone shed some light on whether this is actually feasible, and if so, provide a step-by-step guide to get it working?

Mizux Seiha

unread,
May 5, 2025, 11:56:17 AM5/5/25
to or-tools-discuss
FYI we are testing (still experimental) emscripten build

Github workflow:
https://github.com/google/or-tools/actions/workflows/amd64_web.yml

building the Dockerfile (to get the setup):
https://github.com/google/or-tools/blob/stable/cmake/docker/web/Dockerfile

note: Had to disable all tests since EXPECT_DEATH is not available, should try to disable only few of them instead....

Mizux Seiha

unread,
May 5, 2025, 12:00:17 PM5/5/25
to or-tools-discuss
notice that i'm currently disabling most third party solvers so only cp-sat and glop are available...

ps: emscripten is currently a low priority with zero human ressource allocated to it but it's something we will be happy to make it work with a nice sample for usage is someone want to contribute...

Sebastián José

unread,
May 15, 2025, 12:11:13 PM5/15/25
to or-tools-discuss

I wasn’t aware that the library was being adapted for WebAssembly compilation — that sounds incredible and would open up an entirely new dimension for decision models.

Regarding compilation, the modules I’m most interested in working with are CP-SAT, MIP using Glop, and Routing. From what I understand, it is currently possible to compile these modules. I would truly appreciate it if you could share a guide or some steps to achieve the compilation and eventually build my C++ program into a .wasm file. I’m not an expert in this area, so any support would be highly valuable.

In relation to your comment about the lack of dedicated human resources for this task, I’d like to ask:

  1. What are the main challenges currently preventing full support?

  2. What knowledge or skills are required to contribute meaningfully?

  3. In what ways can someone actively support or contribute to the effort?

I would genuinely love to contribute, because I strongly believe this could be a game changer for decision models that can run directly in the browser using the client’s own resources.

kjart...@gmail.com

unread,
May 15, 2025, 12:38:39 PM5/15/25
to or-tools-discuss
There was some experimental work on this almost five years ago:
Feature request: A browser-friendly version of or-tools (emscripten) · google/or-tools · Discussion #2997

I did a first brute-force compiling to wasm, with a write up:
A Suduko Solving Serverless Endpoint Using WebAssembly and OR-Tools | by Kjartan Rekdal Müller | The Startup | Medium

With some help, it even ended up as a PR :D 
Add Wasm32 as target for cross compiling by kjartanm · Pull Request #2404 · google/or-tools

So it was at least possible then. Unfortunately, I have ended up doing other things and haven't had time to follow up on this.

I still it hope it will possible to do this, and best of luck with it!

Kjartan
Reply all
Reply to author
Forward
0 new messages