-
Notifications
You must be signed in to change notification settings - Fork 47
Problem compiling for wasm #276
Comments
Hm, to be perfectly honest, I'd be pretty surprised if libtcod just built for webassembly without any changes. Though I guess it might work with emscripten. I'd start there, building libtcod directly before trying tcod-rs. It is possible to override a build script: https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts I don't know how that would work (or if it even is possible) with the webassembly backends, though. Actually, I'm not sure how one would build a mix of C and Rust for wasm. I guess llvm can possibly create the object files for both and link that? I'd definitely be interested in seeing this happen, but I don't have the requisite knowledge or time to do this. If you do get it working, I'd love to see it and would definitely be interested in merging it here! |
@tomassedovic I'm lacking time to explore this in the short run as well. I'll have a look at compiling libtcod with emscripten as soon as I can and keep you posted if I have news. Cheers! |
I'm having a similar error on Linux (so we can drop the "on macOS" part in the title). I'm now trying to build export PKG_CONFIG_ALLOW_CROSS=1
export CC=emcc
cargo build --target=wasm32-unknown-emscripten And I'm hitting this error
I'm afraid what you suggested turns out to be true, @tomassedovic: libtcod itself might need some patching to support compiling on web assembly with emscripten. FYI, here is my fork where I changed the |
@ThibaultLemaire I believe we should put our effort in libtcod if we want to get it up and running either with emscripten or wasm. |
@tanis2000 Unfortunately, I'm really no expert in C++ and this is about as far as my interest in porting libtcod to webassembly can stretch. There's also the issue of the outdated version of libtcod that tcod-sys is using... In the end I'd be more interested in translating libtcod to Rust. |
Actually a port of libtcod to rust would be really nice. I’ve been thinking about that but it would require quite a lot of work and I really do not have the time for it |
Hey @tanis2000 @ThibaultLemaire, before you jump into that, I'd just like to make sure you're aware of doryen-rs: https://github.com/jice-nospam/doryen-rs (made by Jice, the original libtcod author IIRC) and RLTK_RS: https://github.com/thebracket/rltk_rs (made by TheBracket, author of Nox Futura). I have not tried either of them much, personally, but they're both projects in a similar vein, written in pure Rust and they both support compiling to webassembly. Both projects are also actively maintained. Sorry for not mentioning them earlier, they slipped my mind. But they might be an interesting alternative to look into. I'd actually like to add them to our README as alternatives. |
Yeah don't worry I wasn't in that much of a hurry to port libtcod to rust. I can imagine the amount of work that represents.
Yup, it looks like the guy holds most of the early commits of libtcod
Please do!
Well I'm happy you spared me the trouble of having to search for myself! I think I'll try to port my roguelike tutorial result to doryen-rs, that'll be fun! |
Porting complete! |
I've been playing around with rltk and it's a pretty good library as well, I recommend it |
This project has not been maintained for a few years. I'm closing all pull requests and issues before archiving the repo on github. Sorry I hadn't done this sooner! |
I'm trying to get
tcod-rs
to compile for wasm (actually the wasm32-unknown-emscripten target) but I'm getting some errors about the underlying C code and I'm having a hard time finding out the reason why.I guess there should be a way to tell emscripten to compile libtcod on its own and use that output as the library to link but I'm not sure this is actually happening.
Any help would be greatly appreciated.
Here's the command I'm running to compile my project that has tcod-rs 0.13 as a dependency:
The result is the following output:
The text was updated successfully, but these errors were encountered: