Skip to content

Getting started & Integrating C++ WASM with React #19869

Answered by verySmolBrain
IssaAboudi asked this question in Q&A
Discussion options

You must be logged in to vote

If you haven't gotten this working yet:

You'll probably need to add the -sEXPORTED_FUNCTIONS=_add_two flag otherwise your add_two function gets eliminated as dead code by the compiler. You'll also have to wrap your function in extern "C" {} to prevent name mangling if you're using C++.

If you're getting started with C++ and WASM, I'd also personally look into the Embind or WebIDL aspects of Emscripten. They have most of the basic features already implemented for you and handles cases like C++ name-mangled functions out of the box. Understanding how they generate bindings would also be beneficial in understanding how the Emscripten toolchain functions.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@IssaAboudi
Comment options

Answer selected by IssaAboudi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants