I was trying to follow the ffi example in the Rustnomicon. I cloned the snappy repository and built it. I placed the snappy library inside the targets/debug/deps/ directory. Here is the code -
use libc::size_t;
#[link(name = "snappy", kind="static")]
extern "C" {
fn snappy_max_compressed_length(source_length: size_t) -> size_t;
}
fn main() {
let x = unsafe { snappy_max_compressed_length(100) };
println!("max compressed length of a 100 byte buffer: {}", x);
}
When I try to build it, it fails with this error -
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
snappy.lib(snappy.obj) : error LNK2019: unresolved external symbol __imp__invalid_parameter referenced in function "void * __cdecl std::_Allocate_manually_vector_aligned<struct std::_Default_allocate_traits>(unsigned __int64)" (??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z)
snappy.lib(snappy-stubs-internal.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
snappy.lib(snappy.obj) : error LNK2019: unresolved external symbol __imp__CrtDbgReport referenced in function "void * __cdecl std::_Allocate_manually_vector_aligned<struct std::_Default_allocate_traits>(unsigned __int64)" (??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z)
snappy.lib(snappy-stubs-internal.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReport
C:\Users\HP\Desktop\rust\c_interop\target\debug\deps\c_interop.exe : fatal error LNK1120: 2 unresolved externals