I have never programmed in Windows, so I don't quite understand how to link the library correctly. I have a compiled Postgres library from under mingw. There is both a static library `*.a` and a dynamic library `*.dll`. I don't understand how to compile my project correctly at all. I tried to do everything through dub first.json, then I realized that the idea was too rash and decided to compile a simple project through the CLI. In the end , here 's what happened:

```sh
PS C:\sources\pxe-restore\source> dmd -i app.d -LC:\msys64\home\user\postgresql-15.1\installed\mingw64\lib\libpq.dll lld-link: error: C:\msys64\home\user\postgresql-15.1\installed\mingw64\lib\libpq.dll: bad file type. Did you specify a DLL instead of an import library? lld-link: error: could not open 'pq.lib': no such file or directory
Error: linker exited with status 1
```

After Googling a bit, I came across [this page](https://wiki.dlang.org/Win32_DLLs_in_D#Using_a_D_class_from_a_DLL). Do I really need to rewrite the header of the Postgres library to use it in my project?

Do I need to list all the functions called from the library? Or is there a way to somehow attach it in a more civilized way through a simple `dmd`?
  • compile: link dy... Alexander Zhirov via Digitalmars-d-learn
    • Re: compile... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: com... Alexander Zhirov via Digitalmars-d-learn
        • Re:... user1234 via Digitalmars-d-learn
          • ... Alexander Zhirov via Digitalmars-d-learn
            • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... Alexander Zhirov via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
                • ... Alexander Zhirov via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
                • ... Alexander Zhirov via Digitalmars-d-learn

Reply via email to