This feature has been added to Cargo and was stabilized in Cargo 1.56. The accepted answer is now out-of-date.
Linker arguments can be specified in build.rs
like so:
// Pass `-fopenmp` to the linker.
println!("cargo:rustc-link-arg=-fopenmp");
More Related Contents:
- How do I convert a Rust closure to a C-style callback?
- What is the right way to allocate data to pass to an FFI call?
- How do I create a Rust callback function to pass to a FFI function?
- How do I pass a closure through raw pointers as an argument to a C function?
- Can a struct containing a raw pointer implement Send and be FFI safe?
- What are non-lexical lifetimes?
- What does “Sized is not implemented” mean?
- Deriving a trait results in unexpected compiler error, but the manual implementation works
- How do I implement Copy and Clone for a type that contains a String (or any type that doesn’t implement Copy)?
- Mutably borrow one struct field while borrowing another in a closure
- How do I convert a Vector of bytes (u8) to a string?
- Can I write an Iterator that mutates itself and then yields a reference into itself?
- How to update-or-insert on a Vec?
- Lifetime troubles sharing references between threads
- How do I include the end value in a range?
- How do I specify lifetime parameters in an associated type?
- How do I invoke a system command and capture its output?
- How to return a string (or similar) from Rust in WebAssembly?
- Can I destructure a tuple without binding the result to a new variable in a let/match/for statement?
- What is the difference between Copy and Clone?
- How to format output to a byte array with no_std and no allocator?
- Efficiently insert or replace multiple elements in the middle or at the beginning of a Vec?
- Calling a generic async function with a (mutably) borrowed argument
- Read large files line by line in Rust [duplicate]
- Why is it discouraged to accept a reference &String, &Vec, or &Box as a function argument?
- What makes `impl Trait` as an argument “universal” and as a return value “existential”?
- How to represent shared mutable state?
- Mutable reference to container object within iterator loop
- How can I pull data out of an Option for independent use?
- Mutable self while reading from owner object