compile: link dynamic OR static library in Windows
aferust at gmail.com
Sat Feb 4 17:02:11 UTC 2023
On Saturday, 4 February 2023 at 15:52:33 UTC, Alexander Zhirov
> PS C:\sources\pxe-restore\source> dmd -i app.d
> 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
> Error: linker exited with status 1
> through a simple `dmd`?
On Windows, dub's default behavior is to search for "foo.lib",
usually compiled with Visual Studio C/C++ compilers. However, you
have mingw-compiled "libfoo.a". I would not use MinGW-compiled
libs with d compilers. I don't know how d compilers improved to
support it, but in the past, I experienced ABI compatibility
issues with d and MinGW.
I took a quick look at https://www.postgresql.org/download/. When
I tried to download, I saw that the archive contained *.lib
files. So, why don't you use them?
you will also need definitions of the functions in your d code
like `extern(C) void fooDB();`. I am not sure how
[importC](https://dlang.org/spec/importc.html) is usable with
PostgreSQL. In addition, there are some bindings in the dub
More information about the Digitalmars-d-learn