rust-lang / rust-lang/rust-bindgen

The compiled code has no functions

Open
#2,989 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/lib.rs and the tripartite/ffmpeg folder, then reproduce the missing-function errors using cargo build --release --target wasm32-unknown-unknown. Trace how bindgen output is included and compare it with the FFmpeg declarations used by src/lib.rs. Done means the required functions are available to the Rust code and the reported build errors are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.