Skip to content

Commit

Permalink
manually call __wasm_call_ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
noname0310 committed Mar 12, 2024
1 parent f53eb31 commit b44cc94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/wasm_src/cpp_src/lib.h
@@ -1,5 +1,9 @@
#include "LinearMath/btScalar.h"

extern "C" {
extern void __wasm_call_ctors();
}

extern "C" int bt_get_version() {
return btGetVersion();
}
6 changes: 6 additions & 0 deletions src/wasm_src/src/lib.rs
Expand Up @@ -3,6 +3,8 @@ use web_sys::console;

#[link(name = "bullet")]
extern "C" {
pub fn __wasm_call_ctors();

pub fn bt_get_version() -> i32;

// pub fn test_function(i: i32) -> i32;
Expand All @@ -25,6 +27,10 @@ extern "C" {

#[wasm_bindgen(js_name = init)]
pub fn init() {
unsafe {
__wasm_call_ctors();
}

console_error_panic_hook::set_once();

unsafe {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.ts
Expand Up @@ -60,7 +60,7 @@ export default (env: any): webpack.Configuration & { devServer?: WebpackDevServe
outDir: path.resolve(__dirname, "src/wasm"),
outName: "index",
extraArgs: "--target web",
forceMode: "production"
forceMode: "development"
})
],
devServer: {
Expand Down

0 comments on commit b44cc94

Please sign in to comment.