0

I have a DLL file that I want to copy to several locations on the computer.

I don't want this file sitting around in my folder like a potato, so I want the file placed directly into the executable and copy it from there instead.

  • 1
    Does this answer your question? [How to embed resources in Rust executable?](https://stackoverflow.com/questions/27140634/how-to-embed-resources-in-rust-executable) – Chayim Friedman Jul 12 '22 at 05:32

1 Answers1

2

Short answer: You can but depending on use case it might not always be best way to get thing done.

Use include_bytes! or include_str!

  • If it is something like README file, Lisence, json config or something use include_str! macro
  • If it is some binary file like DLL you just mentioned use include_bytes

Keep in mind that: If you are trying to enclose raw file which is large in size or you are including multiple files, it will brings all the drawbacks of having huge binary file. Instead you can include the code to download that file if it can be hosted. Even better, if you are distributing your package as application, you can back everything in AppImage or deb file. I believe windows and mac have something similar.

Sudip Ghimire
  • 677
  • 6
  • 15