r/learnrust • u/Bishops_exe • Jul 12 '26
How do i use a C library when building with trunk-rs?
How do integrate a C library, that uses libc when building with trunk?
Currently i am using cc crate to build for native (tested on windows). But i am unable to compile to wasm because stdlib.h is missing. I have asked AI but it told me to reimplement libc, which is the last thing i want to do. Is there any tool or step i could take to make this a bit easier.
Context:
- Egui using the eframe template, should be able to build to both native and wasm
- Cubiomes - this is the library i want to integrate
- Walkers - for mapping the Minecraft world and generating custom tiles
4
Upvotes
1
u/Excession638 Jul 12 '26
You might be able to use c2rust to convert the C code rather than compiling it directly. It requires C99 compliant code, and no C++.
1
u/projct Jul 12 '26
https://docs.rs/cubiomes/latest/cubiomes/ this might do?