DEV Community

Discussion on: WASM in Rust without NodeJS

Collapse
 
davidhur profile image
DavidHur

Hi,
Sorry I'm not familiar with it.

I tried to following this article, when I convert wasm to wat as following code,

[no_mangle]

pub extern fn add(x: u32, y: u32) -> u32 {
x + y

}

But, in my case, have no 'add' function in wat file.

grep export command output as following;

(export "memory" (memory 0))
(export "heap_base" (global 0))
(export "
data_end" (global 1))

(export "rustc_debug_gdb_scripts_section" (global 2))

Am I missed something?

My OS version and rust version as below;
Linux debian 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux
rustup 1.18.3 (435397f48 2019-05-22)
cargo 1.35.0 (6f3e9c367 2019-04-04)

Collapse
 
dandyvica profile image
Dandy Vica

Hi,

Difficult to spot but did you follow the article step by step ?

Collapse
 
davidhur profile image
DavidHur • Edited

I solved it!
Many thanks!

Thread Thread
 
vthg2themax profile image
Vince Pike • Edited

I had the same problem with no created .wasm file, but it was because I missed the step of adding

[lib]
crate-type =["cdylib"]

to the Cargo.toml file. Much appreciated writer! I don't know NodeJS, so when they throw that in, it makes things difficult to understand for a beginner of WebAssembly as it is. :-)