compile: link dynamic OR static library in Windows
azhirov1991 at gmail.com
Sat Feb 4 15:52:33 UTC 2023
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:
PS C:\sources\pxe-restore\source> dmd -i app.d
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
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`?
More information about the Digitalmars-d-learn