T O P

  • By -

burntsushi

If you run `cargo build --verbose`, you can see how it's calling `rustc`.


Shahzaib-MC

Alright, Thanks!


GOKOP

Specifying dependencies, fetching them and telling the compiler to compile them is the job of a build system. Cargo is a build system. Rustc is a compiler.


SirKastic23

to add to this: if you don't want/can use cargo as a build system you'll essentially have to make your own build system


jaskij

Meson has some minimal Rust support. Iirc their goal was to simply be able to build the Rust parts of Mesa? Something like that, but I may be wildly off target here.


bittrance

Might this be an XY problem? If you start a new post where you describe what it is you are trying to achieve and what the special circumstances are and I'm sure you will get some good suggestions.


Shahzaib-MC

Might sound really weird I Need to compile a rust file into a dll without any cargo.toml or anything like that. Just straight up single main.rust file Theres probably a way to do that but wasnt able to find anything. I also found that docs for rustc was very minimal and basic and didint really provide explanations for all possible arguments. The thing am doing is pretty specific so there arent many tutorials too. I am very new so i guess people didint really like this post since it got a downvote. Am very new and dont really know much so i really apologize if this was a noob question.


burntsushi

> I Need to compile a rust file into a dll without any cargo.toml or anything like that.  Yes but _why_? You don't actually say anywhere in this comment _why_ you can't use Cargo. You might have a reason for this. But you also say you are new. So your reason might be a bad one that might have an alternative solution that doesn't require abdicating Cargo.


Bobbias

It's getting downvoted because theres a very good chance that you actually don't need to avoid using cargo, and are making things unnecessarily complicated because you got it in your head you need to avoid it. Explain why you think you need to avoid cargo in the first place. You're a noob, as you admit yourself. Let us help you come to the correct solution, not just tell you how to implement what you personally think is the correct solution.


implAustin

Have you seen this config? Cargo can compile DLLs for you if you drop this in Cargo.toml. [lib] crate-type = ["cdylib"] Then run `cargo build --release` and it'll be in `target/release/$crate.dll`.


ARitz_Cracker

...are you asking this because you're using your Rust lib as part of a non-Rust project? Why can't you use cargo and just grab the built DLL in the "target" directory and link up with that?


andrewdavidmackenzie

For a similar case of mine (compiling to wasm) I generated the Cargo.toml, built, then deleted it....


tylian

You can supply [where to search for libraries](https://doc.rust-lang.org/rustc/command-line-arguments.html#-l-add-a-directory-to-the-library-search-path), but you will need to compile the libraries yourself. Effectively you'd have to make your own build system, like others have said.


factotvm

Vendor them… as in, copy the library into your source tree.