Skip to content

Link C library with Rust project #2317

Open
@MarcAntoine-Arnaud

Description

@MarcAntoine-Arnaud

Describe the Bug

I have a part of the project in C, so I use emscripten to compile it (the complex Makefile is already present, that's why I don't want to use cc).
With emscripten I generate a lib.a file.

On a second time I have a Rust project to integrate the process.
For that I have defined the C API to call FFI from Rust and in the build.rs I add the link to the lib.a.

Using wasm-pack build everything is builded - not tested yet in web environnement.
But in my case I need to target the Web Worker, so I try to compile with wasm-pack build --no-module which provides me that error:

error: cannot import from modules (`env`) with `--no-modules`

Does I missed something ?
Is it linked to a configuration on Emscripten side ?
Does I need to use Wasm in Wasm ? So generate a first wasm with Emscripten, then include bytes in the Rust code ?

Additional Context

Emscripten is used on Ubuntu (docker), Rust on Mac OSX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions