# The Oregon Trail in the browser – FORTRAN 77 to WebAssembly with LFortran

**URL:** <https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070>\
**Category:** LFortran\
**Created:** [August 27, 2026, 2:21pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070 "2026-08-27T14:21:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhdao](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@minhdao](https://fortran-lang.discourse.group/u/minhdao)\
**Post date:** [August 27, 2026, 2:21pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/1 "2026-08-27T14:21:56Z")

</div>

I compiled the 1978 edition of The Oregon Trail — ~1,000 lines of fixed-form FORTRAN 77 — to WebAssembly with LFortran, and it’s [playable in your browser](https://minhqdao.github.io/oregon-fortran-wasm/), even on your phone. Source code is [here](https://github.com/minhqdao/oregon-fortran-wasm).

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 27, 2026, 3:43pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/2 "2026-08-27T15:43:16Z")

</div>

Beautiful, thanks for getting it working!

You should post on X, for now I posted it here: [LFortran on X: "The Oregon Trail in the browser – FORTRAN 77 to WebAssembly with LFortran, by @minhqdao ." / X](https://x.com/lfortranorg/status/2092997379352105314)

Thanks for helping to fix the conda package for LFortran and your bug reports. I see two open: [Issues · lfortran/lfortran · GitHub](https://github.com/lfortran/lfortran/issues?q=is%3Aissue%20state%3Aopen%20author%3Aminhqdao), we’ll fix it.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 1, 2026, 11:17pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/3 "2026-10-01T23:17:11Z")

</div>

How to compile it? Thx.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [October 1, 2026, 11:46pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/4 "2026-10-01T23:46:33Z")

</div>

@Cean instructions are here: [https://github.com/minhqdao/oregon-fortran-wasm#webassembly-build](https://github.com/minhqdao/oregon-fortran-wasm#webassembly-build).

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 3, 2026, 6:23am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/5 "2026-10-03T06:23:39Z")

</div>

```auto
To rebuild them yourself, install LFortran and Emscripten, make sure both are on your PATH, and run:

npm run build:wasm

```

I have built a hello.c file into html file with Emscripten. No need of npm.

But it seems Emscripten can’t do fortran, so you need lFortran. How to build a fortran file into html file without npm under Windows 10?

---

<div class="post-metadata">

**Author:** ![minhdao](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@minhdao](https://fortran-lang.discourse.group/u/minhdao)\
**Post date:** [October 3, 2026, 8:28am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/6 "2026-10-03T08:28:42Z")

</div>

You can try:

1. Compile with LFortran: `lfortran -c --fixed-form --implicit-interface --implicit-typing --target=wasm32-unknown-emscripten hello.f -o hello.o`

2. Link with Emscripten: `emcc hello.o $RUNTIME/lfortran_runtime_wasm_emcc.o -o hello.html`

The scripts are in here: [oregon-fortran-wasm/scripts/build-web.sh at main · minhqdao/oregon-fortran-wasm · GitHub](https://github.com/minhqdao/oregon-fortran-wasm/blob/main/scripts/build-web.sh)

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 7, 2026, 9:55am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/7 "2026-10-07T09:55:32Z")

</div>

Tried on 0.63. Error like this:

```auto
D:\00Fortran\oregon-fortran-wasm-main\hello>lfortran --version
LFortran version: 0.63.0509
Status: alpha (expected to fail on third-party codes)
Platform: Windows
LLVM: 22.1.4
Default target: x86_64-pc-windows-msvc

D:\00Fortran\oregon-fortran-wasm-main\hello>c

D:\00Fortran\oregon-fortran-wasm-main\hello>lfortran -c --fixed-form --implicit-interface --implicit-typing --target=wasm32-unknown-emscripten hello.f -o hello.o
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
LCompilersException: No available targets are compatible with triple "wasm32-unknown-emscripten"

```

Maybe need a new version.

That sh file need to be converted to bat file for Windows.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [October 7, 2026, 10:04pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/8 "2026-10-07T22:04:50Z")

</div>

It might also be a bug on Windows in LFortran. I recommend using an AI agent to isolate the bug and report it to us, if it is our bug.

---

<div class="post-metadata">

**Author:** ![minhdao](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@minhdao](https://fortran-lang.discourse.group/u/minhdao)\
**Post date:** [October 7, 2026, 11:49pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/9 "2026-10-07T23:49:49Z")

</div>

I checked it briefly and it seems like there is a packaging issue on Windows, which is why it wouldn’t work with 0.67.0 either. Maybe you can try WSL2 Ubuntu + LFortran 0.67.0 for now.

---

<div class="post-metadata">

**Author:** ![minhdao](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@minhdao](https://fortran-lang.discourse.group/u/minhdao)\
**Post date:** [October 8, 2026, 9:55am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/10 "2026-10-08T09:55:20Z")

</div>

I opened a PR in `lfortran-feedstock` to support the WASM target on Windows: [Enable the WASM target on Windows by minhqdao · Pull Request #154 · conda-forge/lfortran-feedstock · GitHub](https://github.com/conda-forge/lfortran-feedstock/pull/154)

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 9, 2026, 10:03pm UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/11 "2026-10-09T22:03:06Z")

</div>

Thanks.

I compiled it with vs2022 some times ago. I’ll try to compile it with DWITH\_TARGET\_WASM.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 12, 2026, 12:15am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/12 "2026-10-12T00:15:59Z")

</div>

I added -DLFORTRAN\_BUILD\_TO\_WASM=yes

When build, got an error:

 ![scripten_H](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/d/da747f4946cae868f17c6995a6a3fb6da106f85e.jpeg)

emscripten.h is at emsdk\upstream\emscripten\system\include\emscripten, so I copied this folder into lfortran-main\src, then the error gone.

now only the DIA errors.

 ![scripten_H2](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/a/acbb93f09bdb60fdb432aa1670e86943c0d29442.jpeg)

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 12, 2026, 12:52am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/13 "2026-10-12T00:52:50Z")

</div>

This removes the DIA error.

```auto
C:\Program Files\Microsoft Visual Studio\2022\Community\DIA SDK\lib\amd64\diaguids.lib

```

Now errors are:

 ![scripten_H3](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/6/6b4fb22f2245bb1cd451d824f8d0a6e06f51f67a.jpeg)

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [October 12, 2026, 1:19am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/14 "2026-10-12T01:19:56Z")

</div>

Good progress. Use an AI agent, it can figure all this out for you.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [October 12, 2026, 1:55am UTC](https://fortran-lang.discourse.group/t/the-oregon-trail-in-the-browser-fortran-77-to-webassembly-with-lfortran/11070/15 "2026-10-12T01:55:36Z")

</div>

Tried -DWITH\_LFORTRAN\_ASSERT=NO with a clean build. Now it says:

```auto
Including files directly from the emscripten source tree is not supported. Please use the cache/sysroot/include directory

```

This cache folder is at emsdk\upstream\emscripten\cache

Need to let lfortran uses this:

```auto
emsdk\upstream\emscripten\cache\sysroot\include\emscripten\emscripten.h

```

In lfortran-main\src\bin\lfortran.cpp, make change like this:

```auto
#ifdef HAVE_BUILD_TO_WASM
    #include <emsdk\upstream\emscripten\cache\sysroot\include\emscripten/emscripten.h>
#endif

```

emscripten.h is found. But still got the error from em\_types.h:

```auto

'aligned': identifier not found

```

This seems a MSVC vs. GCC/Clang (emscripten) Syntax Mismatch.

Maybe I need to start with gcc from the beginning now?
