Jump to content
Sign in to follow this  
egnew

FireDAC Cannot Load Postgresql vendor library

Recommended Posts

I installed Postgresql and am unable to connect to the database.

I get the following error when I execute the program and attempt to connect to my database.

image.thumb.png.5b650ee7cedd13314367dc9bc6e9ade5.png

 

My 64 bit program is set for debug and contains a TFDConnection with the appropriate parameters.

Copying libpq.dll from c:\Program Files\PostgreSQL\17\bin into the win64\debug folder did not work.

Adding c:\Program Files\PostgreSQL\17\bin to the system path also does not work.

 

What do I need to do to resolve this issue?


Thanks

Share this post


Link to post

The issue was resolved using a FDPhysPgDriverLink with VendorLib set to the folder containing the libpq.dll.

 

Is FireDac no longer using the path or executable directory for DLL files?

  • Like 1

Share this post


Link to post
18 hours ago, egnew said:

Copying libpq.dll from c:\Program Files\PostgreSQL\17\bin into the win64\debug folder did not work.

In my experience, putting libpg.dll and its dependencies in debug\lib and release\lib works and eliminates having to specify a folder in the driver componenent.

Share this post


Link to post

Thanks.  Placing the DLL in the executable directories is the first thing I tried.  It works for every other DLL I use.  It did not work at all with libpq.dll.

 

When I release the application, libpq.dll will be in the executable directory.

 

I am using Embarcadero® RAD Studio 12 Version 29.0.51961.7529.  Delphi 12 Update 1 with Rad Studio 12.1 Patch 1.

Windows 11 version 23H2 OS Build 22631.4460, 64-bit edition.

Share this post


Link to post
5 minutes ago, egnew said:

When I release the application, libpq.dll will be in the executable directory.

I found that the library files had to be in a sub-directory named lib but that may have changed since I originally started supporting PostgreSQL. I use 12.2 now and just put the files in Debug\lib and Release\lib out of habit.

Share this post


Link to post

The message "Cannot load vendor library libpq.dll" is a little misleading. What I reckon is happening here is that libpq's dependencies cannot be found. If you want to run with libpq in your executable's directory, you also need:

  • libintl-8.dll
  • libcrypto-3-x64.dll
  • libssl-3-x64.dll

These files can be found in the runtime directory of the latest pgadmin.exe or postgresql. For an earlier version of libpq, these dependencies were:

  • libeay32.dll
  • libssl32.dll

Don't ask me when the versions changed!

 

Also, don't forget the MS VC runtime mentioned elsewhere!

 

Hope this helps,

Regards,

Pat

Share this post


Link to post

I would like to thank everyone for their ideas but I posted a solution less than two hours after my original post.  The solution is to set the VendorLib property of a TFDPhysPGDriverLink.

var
  v_pointer: Pointer;
begin
  if SizeOf(v_Pointer) = 4 then
    FDPhysPGDriverLink1.VendorLib := 'C:\PostgreSQL\odbc32\bin\libpq.dll'
  else
    FDPhysPGDriverLink1.VendorLib := 'C:\Program Files\PostgreSQL\17\bin\libpq.dll';

I initially tried putting the appropriate DLLs in the application debug and release folders without success.  I expected that to work as it does with other 3rd-party DLLs.  But It does not work with FireDAC on my machine.

 

I have encountered a number of issues with FireDAC and it is not surprising that I needed to use a DriverLink to resolve the issue.

 

I will no longer follow this topic as I have provided a simple and effective solution.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×