Unresolved external symbol when linking boringssl library

SOLUTION:
I had compiled my library with 32-bit version of MSVC, but Rust compiles programs with 64-bit one. That’s why there was a conflict.

I’m trying to compile my library wrapper of boringssl. I’ve compiled the crypto.lib file that definitely contains the symbol AES_set_encrypt_key, judging by the command:

nm crypto.lib --demangle

Then I’ve generated a FFI file that declares that symbol:

use std::os::raw::{c_void, c_char, c_int, c_uchar, c_uint}; 

#[repr(C)] 
pub struct aes_key_st { 
    pub rd_key: [u32; 60usize], 
    pub rounds: c_uint, 
}

pub type AES_KEY = aes_key_st; 

extern "C" {
    pub fn AES_set_encrypt_key(key: *const u8, bits:c_uint, aeskey: *mut AES_KEY) -> c_int; pub fn foo() -> c_int; 
}

Here are the original C declarations:

struct aes_key_st {
  uint32_t rd_key[4 * (AES_MAXNR + 1)];
  unsigned rounds;
};

typedef struct aes_key_st AES_KEY;

OPENSSL_EXPORT int AES_set_encrypt_key(const uint8_t *key, unsigned bits, AES_KEY *aeskey);

build.rs:

fn main() {
    let out_dir = "<path_to_lib>"
    println!("cargo:rustc-link-search=native={}", out_dir);
    println!("cargo:rustc-link-lib=static=crypto");
}

I am getting an LNK2019 (unresolved external symbol) error when compiling this code.

Why is this happening?

You can build with --verbose and see invocation of the linker. Maybe flags (not) present there will give you more information

Thank you, but I’ve already found solution.