buggins / ddbc

DDBC is DB Connector for D language (similar to JDBC)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot load libpq.dll on Windows

bausshf opened this issue · comments

Does anyone have any idea what causes this? I can't seem to figure it out as libpq.dll is located within the folder of the executable.

I'm on Windows and compiled with dub build -a=x86_mscoff

The screenshot shows the error and dub configurations.

I'm simply trying to compile and run the postgresql example give in the read me.

Am I missing some configurations or setup?

bbbbb

do you need to specify 32 bit? What if you just do dub build? I'm generally on Linux/Mac but have used ddbc in Windows before and it built fine.

Having libpq in the repo seems bad to me, perhaps we could put "preGenerateCommands-windows": [] into the dub.json to download the desired version when building. Something like:

{
    ...
    "preGenerateCommands-windows": [
        "echo downloading libs...",
        "if not exist lib md lib",
        "powershell -Command \"Invoke-WebRequest http://somedomain.com/libpq.dll -OutFile lib\libpq.dll\""
    ]
}

I have to compile with mscoff, else it won't link properly. However it builds fine, but won't run since it can't load the library.

I've also tried with other libpq.dll distributions, so I don't think it's a problem with that file in particular.

It's just like derelict can't locate it for some reason.

The referenced issue does not resolve my issue sadly. I have tried plenty of different libpq.dll's so far.

I just encountered this same issue on 64-bit Windows 10.

I copied the libpq.lib file from my Postgresql install to my project root. This is required to build the project successfully.

If I type "dub" or "dub run" a libpq.dll is automatically copied into my project root. When I run the app I get an error (this is via Vibe.d).

500 - Internal Server Error

Internal Server Error

Internal error information:
derelict.util.exception.SharedLibLoadException@..\..\AppData\Local\dub\packages\derelict-util-2.0.6\derelict-util\source\derelict\util\exception.d(35): Failed to load one or more shared libraries:
	libpq.dll - The specified module could not be found.

So far, the workaround I've found is to copy the libpq.dll from the lib folder of my Postgresql install, build my program using dub build and then run it using prog.exe.

A reasonable solution may be to remove the dll from the repo and require windows users to supply the path to a local installation. Perhaps using "preGenerateCommands-windows": [] to check for the existence of a valid path to libpq.dll

I would've spent time on this before but I rarely use Windows when working on d code

I'm brand new to D and it's tooling but I'm willing to help take a look.

Would it be possible to supply both the (updated) libpq.dll and libpq.lib files as done with SQLite? The version of libpq.dll is three years old now so it might not be comparable with the latest version of libpq.lib (which is what I'm using in my case).