Regarding WASM build

57 views
Skip to first unread message

Velliyangiri A

unread,
Jun 22, 2021, 3:39:02 AM6/22/21
to emscripten-discuss
Dear all,

I have many .c files like hello1.c, hello2.c, etc. All the files are dependent to one project.
So I want to compile all the files and build a .wasm file. 
For compilation, I have specified all the .c files manually in emcc command line like

emcc -g  hello1.c hello2.c hello3.c -s WASM=1 -s EXPORT_ALL=1 -o hello.js -s FORCE_FILESYSTEM=1 -s "EXPORTED_RUNTIME_METHODS=['calls','cwrap']" -s "EXPORTED_FUNCTIONS=['_Hello']" -s ALLOW_MEMORY_GROWTH=1

Is there any way available to load all the .c files without specifying manually in the command line?
Kindly help me.

Referred links
Giri

Thomas Lively

unread,
Jun 22, 2021, 2:46:32 PM6/22/21
to emscripte...@googlegroups.com
Hi Giri,

you may want to look into using a build system rather than specifying all your source files in a single command. I would recommend using Make to start because it is relatively simple. This page looks like a good introduction to it: https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/.

Make will let you speed up your builds by building multiple source files in parallel and by only re-building source files that have changed since your last build.

Best,

Thomas

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/e83551e1-ae66-4195-8e58-709991c4e59bn%40googlegroups.com.

Floh

unread,
Jun 28, 2021, 9:49:07 AM6/28/21
to emscripten-discuss
If you'e on Linux or macOS, you can simply do

emcc *.c ...

because the command line will expand the filename pattern before calling emcc, doesn't work on the Windows command line though, because there the executable itself needs to do expansion. For more complex stuff I'd recommend looking into build tools like cmake or genie (https://github.com/bkaradzic/GENie).
Reply all
Reply to author
Forward
0 new messages