Skip to content

The compiled code has no functions #2989

@axzsd

Description

@axzsd

hello, I'm learning Rust from Java, I'm interested in Rust, and recently I had a difficulty compiling to wasm using Rust+ffmpeg hybrid, bindgen couldn't generate the ffi function I needed.
ffmpeg code location: The "tripartite/ffmpeg" folder in the project project directory. Versions of bindgen I have tried :0.69.5, 0.70.1.

Compile command: cargo build --release --target wasm32-unknown-unknown

System environment:

bindgen version: 0.69.5 - 0.70.1
OS: MacOs Sonoma Version 14.5
Rust edition : "2021"
Rustc Version: rustc 1.82.0 (f6e511eec 2024-10-15)
Cargo Version: cargo 1.82.0 (8f40fc59f 2024-08-21)
CPU: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz

emsdk: The *recommended* precompiled SDK download is 3.1.72 (7a360458327cd24c2a7aab428bdbcb5bca8810e4).
To install/activate it use:
         latest
This is equivalent to installing/activating:
         3.1.72             INSTALLED

emcc Version: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.72 (437140d149d9c977ffc8b09dbaf9b0f5a02db190)

clang Version: 
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: x86_64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

This is an error message

error[E0425]: cannot find function `avformat_alloc_context` in this scope
  --> src/lib.rs:26:56
   |
26 |         let mut format_context: *mut AVFormatContext = avformat_alloc_context();
   |                                                        ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `av_malloc` in this scope
  --> src/lib.rs:33:22
   |
33 |         let buffer = av_malloc(buffer_size) as *mut u8;
   |                      ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `avformat_free_context` in this scope
  --> src/lib.rs:35:13
   |
35 |             avformat_free_context(format_context);
   |             ^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `format_context`

error[E0425]: cannot find function `avio_alloc_context` in this scope
  --> src/lib.rs:56:26
   |
56 |         let io_context = avio_alloc_context(
   |                          ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `av_free` in this scope
  --> src/lib.rs:67:13
   |
67 |             av_free(buffer as *mut std::os::raw::c_void);
   |             ^^^^^^^ not found in this scope

error[E0425]: cannot find function `avformat_free_context` in this scope
  --> src/lib.rs:68:13
   |
68 |             avformat_free_context(format_context);
   |             ^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `format_context`

error[E0425]: cannot find function `avformat_open_input` in this scope
  --> src/lib.rs:75:12
   |
75 |         if avformat_open_input(&mut format_context, ptr::null_mut(), ptr::null_mut(), ptr::null_mut()) < 0 {
   |            ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `avformat_free_context` in this scope
  --> src/lib.rs:77:13
   |
77 |             avformat_free_context(format_context);
   |             ^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `format_context`

error[E0425]: cannot find function `avformat_find_stream_info` in this scope
  --> src/lib.rs:82:12
   |
82 |         if avformat_find_stream_info(format_context, ptr::null_mut()) < 0 {
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `avformat_close_input` in this scope
  --> src/lib.rs:84:13
   |
84 |             avformat_close_input(&mut format_context);
   |             ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `avformat_close_input` in this scope
   --> src/lib.rs:101:13
    |
101 |             avformat_close_input(&mut format_context);
    |             ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `avformat_close_input` in this scope
   --> src/lib.rs:114:9
    |
114 |         avformat_close_input(&mut format_context);
    |         ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `av_free` in this scope
   --> src/lib.rs:153:5
    |
153 |     av_free((*io_context).buffer as *mut c_void);
    |     ^^^^^^^ not found in this scope

error[E0425]: cannot find function `av_free` in this scope
   --> src/lib.rs:154:5
    |
154 |     av_free(io_context as *mut c_void);
    |     ^^^^^^^ not found in this scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions