-
Notifications
You must be signed in to change notification settings - Fork 47
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
Can't build crate as wasm target #115
Comments
I haven't seen any crates with native dependencies buildable in a wasm/browser environment. I'd be interested if there are any working examples of what that could look like. |
Clang does support building wasm32 as a target (I think?) and if not Clang then at least setting the C compiler to Emscripten should work, but I haven't got that to work either. |
|
Maybe relevant: ZSTD added support for
|
Another relevant link rustwasm/team#291 |
I spent a couple minutes trying to build for --- a/proj-sys/build.rs
+++ b/proj-sys/build.rs
@@ -88,6 +88,10 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
let mut archive = Archive::new(tar);
archive.unpack("PROJSRC/proj")?;
let mut config = cmake::Config::new("PROJSRC/proj/proj-8.1.0");
+ config.define("CMAKE_TRY_COMPILE_TARGET_TYPE", "STATIC_LIBRARY");
+ config.define("CMAKE_C_COMPILER_WORKS", "1");
+ config.define("CMAKE_CXX_COMPILER_WORKS", "1");
+ config.define("USE_THREAD", "0");
config.define("BUILD_SHARED_LIBS", "OFF");
config.define("BUILD_TESTING", "OFF");
config.define("BUILD_CCT", "OFF"); |
IMO That leaves When I run
I get
sqlite3 can be built to WASM via emscripten (see https://github.com/sql-js/sql.js). So the next step would be figuring out how to first build sqlite3 via emscripten then use that built sqlite3 to link to proj. Maybe relevant: https://emscripten.org/docs/compiling/Building-Projects.html#using-libraries |
There seems to be a Proj build for WASM: https://github.com/jvail/spl.js |
Has anyone had any luck compiling for WASM? |
Also a note that someone on this rust+wasm+c thread seems to have made an example repo for creating a wasm-pack build using targets other than |
Useful thread: rustwasm/team#291 |
An (very!) initial release of proj-wasm is now available, and I'd be more than happy to discuss what would be useful for you all here: |
Hi, Do you have any suggestions or ideas on how I can approach this integration? |
Rust isn’t my strong suit, unfortunately. I think the C++ was compiled via emscripten, but with mangled function names, though I believe there’s a way to unmangle some C++ stuff. I’ve been focusing on just implementing the C API though — that’s what emscripten does most easily, and it’s also what lines up best with my parallel FFI work on the JVM (which at the moment is also C-only.) |
The text was updated successfully, but these errors were encountered: