alexcrichton / curl-rust

Rust bindings to libcurl
MIT License
1k stars 234 forks source link

How to Build This Project On Ubuntu Linux #488

Open bhaijiyunus opened 1 year ago

bhaijiyunus commented 1 year ago

HI,

From the README it seems that the steps mentioned is to build on Window's system. Can you share or add how to build this project on Ubuntu Linux.

I just clone this project on Ubuntu Linux & simply did, but stuck with some error. image

Please help to build this project on Linux. FYI, I am new to the Rust world, just beginner.

Thanks, Yunus

sagebind commented 1 year ago

Welcome to Rust!

curl-rust is not an application that can be run, so you cannot use cargo run as there is no main function to run. Rather, curl-rust is a library that you can add as a dependency to your application to use. For example, you can create a new Cargo project using cargo new and then add curl-rust as a dependency to your project using cargo add curl. See also this section in The Cargo Book. You do not need to clone this repository in order to use it as a dependency in your code.

That said, if you just want to compile curl-rust by itself, you can do so with cargo build.

bhaijiyunus commented 1 year ago

Hey Sagebind,

Thanks for the response. Can we do client certificate based HTTPS API call with curl-rust? I have the end point which require the client certificate & key for authentication. I am able to test the API with simple curl command but looking for help to do in Rust.

Thanks, Yunus

sagebind commented 1 year ago

Sure, you can supply client certificates using the appropriate options in your request. curl-rust is a pretty thin wrapper around the libcurl C API, so generally any examples using libcurl you can find will translate pretty easily to Rust.

Pro tip: If you add the --libcurl flag to whatever curl command you want to replicate, and it will output a full C program that uses the libcurl API to perform a request equivalent to the CLI command. The methods on the Easy struct will generally have the exact same name as the C equivalent CURLOPT_* name.