Re: compile: link dynamic OR static library in Windows

2023-02-06 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 08:23:37 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] Yes, your solution works. I apologize for my inattention. I should have checked earlier in your way. Most likely Adam has a [problem](https://github.com/adamdruppe/arsd/issues/364) with linking in the

Re: compile: link dynamic OR static library in Windows

2023-02-06 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 06/02/2023 8:43 PM, Alexander Zhirov wrote: Is it possible to collect all this from under mingw so that the linker is not Microsoft, but `ld'? Maybe. Keep in mind that mingw isn't the system toolchain, you'll probably run into issues using it else where. You should really be using MSVC.

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 06:59:09 UTC, Richard (Rikki) Andrew Cattermole wrote: On other platforms the -Lfile I think would work. On Windows you have to link against the import library not DLL directly. You can pass it to the compiler: $ dmd -i "-L/LIBPATH:C:\Program Files\PostgreSQL\15

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On other platforms the -Lfile I think would work. On Windows you have to link against the import library not DLL directly. You can pass it to the compiler: $ dmd -i "-L/LIBPATH:C:\Program Files\PostgreSQL\15\lib" pq.lib app.d Should work. Sorry, I should have revisted this from the get go, rat

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 05:45:35 UTC, Richard (Rikki) Andrew Cattermole wrote: Ah doh, MSVC link doesn't use -L. $ dmd -i "-L/LIBPATH:C:\Program Files\PostgreSQL\15\lib" -Llpq app.d I think that is the option you want. Worst case scenario just copy the files to your working directory

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Ah doh, MSVC link doesn't use -L. $ dmd -i "-L/LIBPATH:C:\Program Files\PostgreSQL\15\lib" -Llpq app.d I think that is the option you want. Worst case scenario just copy the files to your working directory and it should find it without the additional search path.

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 06/02/2023 6:16 PM, Alexander Zhirov wrote: C:\sources\pxe-restore\source>dmd -i app.d -L'-LC:\Program Files\PostgreSQL\15\lib' -Llpq Source files go after flags. $ dmd -i -L'-LC:\Program Files\PostgreSQL\15\lib' -Llpq app.d

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 05:20:33 UTC, Richard (Rikki) Andrew Cattermole wrote: Source files go after flags. $ dmd -i -L'-LC:\Program Files\PostgreSQL\15\lib' -Llpq app.d For some reason, the `obj` file is link instead of the library. ```sh C:\sources\pxe-restore\source>dmd -L'-LC:\Progr

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Sunday, 5 February 2023 at 13:37:16 UTC, user1234 wrote: try ``` dmd -i app.d -L'-LC:\Program Files\PostgreSQL\15\lib' -Llpq ``` the first linker command gives a search path, the second a libname. It doesn't work ```sh C:\sources\pxe-restore\source>dmd -i app.d -L'-LC:\Program Files\Pos

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 February 2023 at 11:52:01 UTC, Alexander Zhirov wrote: On Saturday, 4 February 2023 at 15:56:41 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] I don't understand why the compiler doesn't see the library. ```sh User@WIN-D3SHRBHN7F6 MINGW64 /home/user/pxe-restore/source # ls -

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
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

Re: compile: link dynamic OR static library in Windows

2023-02-04 Thread Alexander Zhirov via Digitalmars-d-learn
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 kn

Re: compile: link dynamic OR static library in Windows

2023-02-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Saturday, 4 February 2023 at 15:52:33 UTC, Alexander Zhirov wrote: 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 yo

Re: compile: link dynamic OR static library in Windows

2023-02-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
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. For dub, it should be as sim