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

How is wasm compiled? #4

Closed
iflyyun opened this issue Feb 7, 2023 · 2 comments
Closed

How is wasm compiled? #4

iflyyun opened this issue Feb 7, 2023 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@iflyyun
Copy link

iflyyun commented Feb 7, 2023

No description provided.

@61315
Copy link
Owner

61315 commented Feb 7, 2023

I'm assuming you already have the emcc installed someplace.

It starts with compiling each source into emcc object files.

emcc -DSYNTH_LIB_ALONE -O3 -s resynthesizer/engine.c -c -o engine.o
emcc -DSYNTH_LIB_ALONE -O3 -s resynthesizer/engineParams.c -c -o engineParams.o
emcc -DSYNTH_LIB_ALONE -O3 -s resynthesizer/glibProxy.c -c -o glibProxy.o
emcc -DSYNTH_LIB_ALONE -O3 -s resynthesizer/imageFormat.c -c -o imageFormat.o
emcc -DSYNTH_LIB_ALONE -O3 -s resynthesizer/imageSynth.c -c -o imageSynth.o
emcc -DSYNTH_LIB_ALONE -O3 -s resynthesizer/progress.c -c -o progress.o

And assemble them into a library.

emar rcs libresynthesizer.a engine.o engineParams.o glibProxy.o imageFormat.o imageSynth.o progress.o

And then compile the sample program (painter_wasm.c) while linking against the built library. libresynthesizer.a in this case.

emcc -O3 -flto -o interactive.html examples/painter_wasm.c -Iresynthesizer libresynthesizer.a -s USE_SDL=2 --preload-file=assets/source001.ppm

Then you get a nice, cool-looking interactive demo. ;)

If you need help with anything else, you can read the emscripten manual.
https://emscripten.org/docs/getting_started/Tutorial.html

@iflyyun
Copy link
Author

iflyyun commented Feb 7, 2023

wow!Thank you very much!

@61315 61315 self-assigned this Feb 7, 2023
@61315 61315 added the question Further information is requested label Feb 7, 2023
@61315 61315 pinned this issue Feb 7, 2023
@61315 61315 closed this as completed Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants