wasm-tool / emscripten Goto Github PK
View Code? Open in Web Editor NEWEmscripten loader for webpack
License: MIT License
Emscripten loader for webpack
License: MIT License
Hi, can you assist on an issue im having.
Heres my project for reference: https://github.com/AHaliq/wasmtest
I've created a create-react-app
and ran npm run eject
and updated the config/webpack.config.js
accordingly for your loader. I've added a cpp file in my src as such
#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE
int add(int x, int y) {
return x + y;
}
and in index.js
import { add } from './hello_world.cpp';
console.log(add(5,10));
Everything seems fine but I'm getting unable to compile error
Failed to compile.
./src/hello_world.cpp
Error: Command failed: emcc hello_world.cpp -O3 -s WASM=1 -s MODULARIZE=1
warning: honoring legacy environment variable `NODE`. Please switch to using `EM_NODE_JS` instead`
hello_world.cpp:1:8: error: expected template
export default __webpack_public_path__ + "static/media/hello_world.905deec9.cpp";
^
hello_world.cpp:1:8: error: expected unqualified-id
2 errors generated.
emcc: error: '/Users/haliq/Desktop/zkp_research/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=25 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/Users/haliq/Desktop/zkp_research/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -O3 hello_world.cpp -c -o /var/folders/f6/128r_qx57953hch5znq5npq00000gn/T/emscripten_temp_nl9vsukn/hello_world_0.o' failed (returned 1)
running the commands individually however works fine
emcc hello_world.cpp -O3 -s WASM=1 -s MODULARIZE=1
and
/Users/haliq/Desktop/zkp_research/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=25 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/Users/haliq/Desktop/zkp_research/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -O3 hello_world.cpp -c -o ./hello_world_0.o
runs fine
I just noticed that we left some unused in the main package: https://github.com/wasm-tool/emscripten/blob/master/package.json#L11-L12. Those should be moved into the example folder.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.