Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build on wasm32-unknown-unknown due to libc malloc #43

Closed
carado opened this issue Dec 21, 2019 · 2 comments · Fixed by #51
Closed

Unable to build on wasm32-unknown-unknown due to libc malloc #43

carado opened this issue Dec 21, 2019 · 2 comments · Fixed by #51

Comments

@carado
Copy link

carado commented Dec 21, 2019

Creating a project with lodepng as a dependency and building with --target wasm32-unknown-unknown yields the following errors:

   Compiling lodepng v2.5.0
error[E0425]: cannot find function `malloc` in crate `libc`
  --> /home/carado/.cargo/registry/src/github.com-1ecc6299db9ec823/lodepng-2.5.0/src/rustimpl.rs:53:15
   |
53 |         libc::malloc(size) as *mut _
   |               ^^^^^^ not found in `libc`

error[E0425]: cannot find function `realloc` in crate `libc`
  --> /home/carado/.cargo/registry/src/github.com-1ecc6299db9ec823/lodepng-2.5.0/src/rustimpl.rs:58:11
   |
58 |     libc::realloc(ptr as *mut _, size) as *mut _
   |           ^^^^^^^ not found in `libc`
   |
help: possible candidate is found in another module, you can import it into scope
   |
16 | use std::alloc::realloc;
   |

error[E0425]: cannot find function `free` in crate `libc`
  --> /home/carado/.cargo/registry/src/github.com-1ecc6299db9ec823/lodepng-2.5.0/src/rustimpl.rs:62:11
   |
62 |     libc::free(ptr as *mut _)
   |           ^^^^ not found in `libc`

error[E0425]: cannot find function `free` in crate `libc`
   --> /home/carado/.cargo/registry/src/github.com-1ecc6299db9ec823/lodepng-2.5.0/src/lib.rs:818:11
    |
818 |     libc::free(ptr as *mut _);
    |           ^^^^ not found in `libc`

error: aborting due to 4 previous errors

Is using the system's malloc and free really necessary ?

@kornelski
Copy link
Owner

WASM seems to have malloc: https://github.com/rust-lang/libc/pull/1092/files maybe you need rustup update/cargo update?

@carado
Copy link
Author

carado commented Dec 22, 2019

I tried using the latest lodepng and latest nightly rustc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants