Closed aishwaryagm1999 closed 2 years ago
I'm going to close as this appears to be an issue with using a third-party library. The rust-lang/rust issue tracker is for issues specific to the compiler. Questions like these are best asked on one of the user forums (and it looks like you have asked on https://users.rust-lang.org/t/openssl-error-could-not-find-native-static-library-c-perhaps-an-l-flag-is-missing/75476).
Also, some tips for more likely getting some assistance:
openssl
dependency? Can you remove chunks of your code? The more minimal your example is the more likely someone can help. See Minimal, Reproducible Example
I get the following error when I try to run the below code for a DTLS client server program using rust through visual studio code and its terminal. I have already installed openssl libraries using vcpkg and set the environment variables. I have also installed the c/c++ extensions for vscode.
Error: error: could not find native static library C, perhaps an -L flag is missing? How do I resolve this error? My DTLS code is given below along with build.rs and cargo.toml. I get the same error when I try to run any openssl-dependant codes in C/C++/Rust.
MAIN.rs
let connector = DtlsConnector::builder() .add_srtp_profile(SrtpProfile::Aes128CmSha180) .add_srtp_profile(SrtpProfile::AeadAes256Gcm) .add_root_certificate(root_ca) .build() .unwrap(); let server = UdpSocket::bind("127.0.0.1:0").unwrap(); let client = UdpSocket::bind("127.0.0.1:0").unwrap(); let server_addr = server.local_addr().unwrap(); let client_addr = client.local_addr().unwrap(); let server_channel = UdpChannel { socket: server, remote_addr: client_addr, }; let client_channel = UdpChannel { socket: client, remote_addr: server_addr, }; let guard = thread::spawn(move || { let mut dtls_server = acceptor.accept(server_channel).unwrap(); let mut count = 0; while true { let mut received = [0; 5]; dtls_server.read_exact(&mut received); println!( "{:?} {:?}", count, String::from_utf8_lossy(received.as_ref()) ); count = count + 1; thread::sleep(Duration::from_millis(2)); } }); let mut dtls_client = connector.connect("foobar.com", client_channel).unwrap(); while true { let mut buf = [0; 5]; let buf = b"hello"; dtls_client.write_all(buf); thread::sleep(Duration::from_millis(30)); } } CARGO.toml
BUILD.rs
BUILD.rs use std::fs::File; use std::io::Write; use std::process::Command; use std::env; fn main() -> std::io::Result<()> {
} For further reference please check this link for full code: https://github.com/TimonPost/udp-dtls