compile: link dynamic OR static library in Windows

Alexander Zhirov azhirov1991 at gmail.com
Sat Feb 4 17:45:45 UTC 2023


On Saturday, 4 February 2023 at 17:02:11 UTC, Ferhat Kurtulmuş 
wrote:
> 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 can't link to the library `*.a` and I don't understand why?

```sh
PS C:\sources\pxe-restore\source> dmd -i app.d 
C:\msys64\home\user\postgresql-15.1\installed\mingw64\lib\libpq.a
Error: unrecognized file extension a
```

Is there any way to convert the library `dll` to `lib`? Without 
using Visual Studio?

On Saturday, 4 February 2023 at 17:02:11 UTC, Ferhat Kurtulmuş 
wrote:
> 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 
> registry https://code.dlang.org/search?q=PostgreSQL.

At this stage, everything is fine. I'm using a project that I 
build on Linux without any problems. All connections are set up 
there.


More information about the Digitalmars-d-learn mailing list