Hi all,
I have a project that compiles C++ to wasm/javascript using emscripten. But I am having trouble getting the class defined via embind to instantiate in my javascript.
This is my makefile:
# webassembly
CC=em++
CFLAGS=-std=c++11 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s SAFE_HEAP=1 -Oz -g4 -s ASSERTIONS=1
DEPS=-I eigen
LINK=-s LINKABLE=1 -c
wasm: Settings.h Settings.cpp Vertex.h Vertex.cpp Edge.h Edge.cpp BarnesHutNode3.h BarnesHutNode3.cpp LayoutGraph.h LayoutGraph.cpp DynamicMatching.h
$(CC) $(CFLAGS) $(DEPS) $(LINK) Settings.cpp -o build/Settings.o
$(CC) $(CFLAGS) $(DEPS) $(LINK) Vertex.cpp -o build/Vertex.o
$(CC) $(CFLAGS) $(DEPS) $(LINK) Edge.cpp -o build/Edge.o
$(CC) $(CFLAGS) $(DEPS) $(LINK) BarnesHutNode3.cpp -o build/BarnesHutNode3.o
$(CC) $(CFLAGS) $(DEPS) $(LINK) LayoutGraph.cpp -o build/LayoutGraph.o
$(CC) $(CFLAGS) $(DEPS) $(LINK) DynamicMatching.cpp -o build/DynamicMatching.o
$(CC) $(CFLAGS) $(DEPS) build/Settings.o build/Vertex.o build/Edge.o build/BarnesHutNode3.o build/DynamicMatching.o --bind -s ENVIRONMENT='web' -o build/fourd.js
I'm trying to follow best practices for a web project, so I experimented with rollup and webpack, but I thought my issue might be more fundamental than that.
When I include the generated fourd.js in a webpage, I get a "run is not a function" error in Firefox.
Is there something wrong with my compilation process?
Josh