Skip to content

Unable to instantiate logger due to error message which originates from wasm-bindgen #3447

Closed
@lexi-the-cute

Description

@lexi-the-cute

Summary

When running console_log::init().unwrap(); from the below code, I get the error message: function not implemented on non-wasm32 targets on Firefox.

if cfg!(any(target_arch = "wasm32", target_arch = "wasm64")) {
    console_log::init().unwrap();
}

Additional Details

The build script is really complicated right now. I currently call SDL_main as I have not been able to get any indication of the code running in console if I attached the wasm_bindgen macro at all.

// Run as Library (e.g. Android and WebAssembly)
#[no_mangle]
#[allow(non_snake_case)]
pub extern fn SDL_main(_argc: libc::c_int, _argv: *const *const libc::c_char) -> libc::c_int {
    game::start();
    return 0;
}

I'm using:

console_log = { version = "1.0.0", features = ["color", "wasm-bindgen"] }
wasm-bindgen = "0.2.86"

I'm calling my wasm file with the below code after I generate both the js and wasm file with emmc:

<script type="text/javascript">
var Module = {
    onRuntimeInitialized: function() {
        Module._SDL_main(); // SDL_main was exported
    }
};
</script>
<script src="/main.js"></script>

My project is located at https://github.com/alexisart/catgirl-engine

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions