emscripten-core / emscripten-core/emscripten

Failed to load resource

Aperta
#23,949 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C++
Stelle
27.6k
Fork
3.6k
Merge medio
1g 14h
PR unite (30g)
125

Descrizione

Please include the following in your bug report:

Version of emscripten/emsdk:

$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.5-git (53b38d0c6f9fce1b62c55a8012bc6477f7a42711)
clang version 21.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin

Failing command line in full:

I was just customize Using files example
from Emscripten Tutorial page:

$ mkdir -p out/static
$ ./emcc test/hello_world_file.cpp -o out/static/hello.mjs --preload-file test/hello_world_file.txt
$ cat > out/index.html << EOL
<!DOCTYPE html>
<html>
<body>
        <script type="module">
                import initModule from './static/hello.mjs';
                initModule({
                        print: (text) => { document.body.innerText += text + '\n'; }
                });
        </script>
</body>
</html>
EOL
$ ./emrun out/index.html

Failure from browser console:

Failed to load resource: the server responded with a status of 404 (File not found: <current path>/out/hello.data)

Module hello.mjs search hello.data in out subdirectory (local webserver root). But hello.mjs sould search hello.data from ./static/ supdirecotry where hello.mjs hosted himself.

Then we mode hello.data to out from out/static and run again:

$ mv out/static/hello.data out/
$ ./emrun out/index.html

And see text in browser:

==
This data has been read from a file.
The file is readable as if it were at the same location in the filesystem, including directories, as in the local filesystem where you compiled the source.
==

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema con test/hello_world_file.cpp, test/hello_world_file.txt e il comando emcc che genera out/static/hello.mjs e hello.data. Esamina come hello.mjs risolve il file di dati quando viene caricato da out/index.html, quindi esegui emrun e verifica che l’esempio carichi il file senza spostare hello.data in out.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, wasm
Ambito
build-system, web-dev
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.