ld: Undefined symbols for Opus crate

36 views Asked by At

Trying to develop an audio streaming application in Rust that uses the Opus encoding. I'm using this crate. I have a function here that takes samples and encodes them:

fn encode_to_opus(samples: &[f32], encoder: &mut Encoder) -> Vec<u8> {
    let max_output_size = samples.len() * 2; // 2x compression ratio
    let mut output_buffer = vec![0u8; max_output_size];

    let encoded_size = encoder.encode_float(samples, &mut output_buffer).unwrap();

    // Trim the output buffer to the actual encoded size
    output_buffer.resize(encoded_size, 0);

    output_buffer
}

When I compile and run, I get the following error:

ld: warning: ignoring file '/Users/zacharyhaslam/RustPlayground/cpal_testing/target/debug/deps/libaudiopus_sys-b06e984177d2e5d2.rlib[24](pitch_sse.o)': found architecture 'x86_64', required architecture 'arm64'
          ld: Undefined symbols:
            _opus_encode_float, referenced from:
                opus::Encoder::encode_float::h96d337e69d049c7b in libopus-d4d6cdcdfd802711.rlib[3](opus-d4d6cdcdfd802711.opus.a73d87a4e4c4d0c0-cgu.0.rcgu.o)
            _opus_encoder_create, referenced from:
                opus::Encoder::new::ha44c447e84244c35 in libopus-d4d6cdcdfd802711.rlib[3](opus-d4d6cdcdfd802711.opus.a73d87a4e4c4d0c0-cgu.0.rcgu.o)
            _opus_encoder_destroy, referenced from:
                _$LT$opus..Encoder$u20$as$u20$core..ops..drop..Drop$GT$::drop::hc38a18cae3d66bd4 in libopus-d4d6cdcdfd802711.rlib[3](opus-d4d6cdcdfd802711.opus.a73d87a4e4c4d0c0-cgu.0.rcgu.o)
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I ran cargo clean and tried reinstalling the crate, and no luck. I'm running on an M1 Mac, and I'm sure that's got something to do with it. Are there any changes to my Cargo.toml file that could help fix?

0

There are 0 answers