On Tuesday, 19 January 2021 at 11:10:25 UTC, Marcone wrote:
On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote:
On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote:
How can I create a Standalone Bundle Portable file application using Dlang?

Could you describe what you mean with "Bundle portable file application"?

All dependencies inside an exe file. Like Python Pyinstaller.

One possible way is to use import() operator to embed file into resulting artifact, then write it to disk in main or module ctor and load as usual. note however you need to tell compiler about file lookup path (-J flag) or use dub string import path respectively.

  // compile time
  enum myEmbeddedFile = import("path/to/file");

  // pseudocode
  void main()
  {
    // write file at runtime
    write(cast(ubyte[]) myEmbeddedFile, "./myfile.ext");

    // or use directly from memory
    writeln(myEmbeddedFile)
  }

this however not possible with implicit dynamic linking, though you still can use this approach if you do use LoadLibrary/dlopen yourself.

Reply via email to