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

failed to compile #3

Open
AHaliq opened this issue Jul 15, 2021 · 0 comments
Open

failed to compile #3

AHaliq opened this issue Jul 15, 2021 · 0 comments

Comments

@AHaliq
Copy link

AHaliq commented Jul 15, 2021

Hi, can you assist on an issue im having.

Project Setup

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

The issue

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant