compile: link dynamic OR static library in Windows

Alexander Zhirov azhirov1991 at gmail.com
Sun Feb 5 11:52:01 UTC 2023


On Saturday, 4 February 2023 at 15:56:41 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On Windows you don't link directly against a DLL.
>
> You link against a static library (.lib) of the same name.
>
> The binding doesn't change between a static library and a 
> shared library as long as you're linking during the compilation 
> sequence and not during runtime.

I don't understand why the compiler doesn't see the library.

```sh
User at WIN-D3SHRBHN7F6 MINGW64 /home/user/pxe-restore/source
# ls -la "C:\Program Files\PostgreSQL\15\lib\libpq.lib"
-rw-r--r-- 1 User Отсутствует 37002 Nov  9 06:45 'C:\Program 
Files\PostgreSQL\15\lib\libpq.lib'

User at WIN-D3SHRBHN7F6 MINGW64 /home/user/pxe-restore/source
# dmd -i app.d -L'C:\Program Files\PostgreSQL\15\lib\libpq.lib'
lld-link: error: could not open 'pq.lib': no such file or 
directory
Error: linker exited with status 1
```


More information about the Digitalmars-d-learn mailing list