I am trying to build a Rust library which can use the Opus codec. When compiling for x86_64-pc-windows-msvc everything works as expected. However when I compile for i686-pc-windows-msvc I get errors about unresolved externals. e.g.
error LNK2001: unresolved external symbol _opus_encoder_create
Obviously this is failing because it's looking for the wrong name! There shouldn't be a leading underscore there. My Rust import looks like:
extern "C" {
pub fn opus_encoder_create(fs:i32, chan:i32, app:i32, err:*mut i32) -> *mut OpusEncoder;
}
It looks like Rust is automatically inserting the underscore at the start. Running dumpbin on both the 32 bit and 64 bit lib files (built in Visual Studio) gets me:
32 bit:
> 7202A opus_encoder_create
64 bit:
> 7202A opus_encoder_create
No underscores in sight!
What am I doing wrong? How do I properly import and call these functions from Rust?