Jump to content
Adam

PostgreSQL FireDAC in the Delphi IDE? (Cannot load vendor library libpq.dll)

Recommended Posts

Hi All,

 

Just wondering if someone can please tell me if I'm expecting too much from Delphi. I'm wanting to develop my first PostgreSQL application. 

 

I have installed PostgreSQL v 18. I am wanting to active the TFDConnection component so I can link tables, and load persistent fieldnames in automatically, but I keep getting the error:

 

Cannot load vendor library [p:\path\pgpath\libpq.dll]. The specified module could not be found Hint: check it is in the PATH or application EXE directories, and has x86 bitness..

(It's showing the path because I've dropped a FDPhysPgDriverLink component in an attempt to force it to use that DLL - it fails with or without this).

From my research, it seems that I should be able to get the Delphi IDE to connect to the database server by using older 32 bit versions of the dll's. I extracted libpq.dll from both version 10 and version 9 32 bit versions and extracted it to the location above (which is also in the path directory), but always get the above error. 

 

I'm aware that I need to be compiling 64 bit applications to work with the database (and that's OK), but for purely the design time development of the TFDTable and query components, I am used to being able to connect to databases in the IDE at designtime to confirm my queries and tables are right, and to load the persistent field properties.  Is this the wrong way to be going about things now? Am I expected to manually create my persistent fields one at a time for future development? 

 

I have confirmed all DLL's in this path are 32bit only. I'm not sure if I'm missing a dependency. These are the DLL's that I have in that path:

 

libeay32.dll

libiconv-2.dll

libintl-8.dll

libpq.dll

msvcp120.dll

msvcr120.dll

ssleay32.dll


Is this the wrong way to be developing in Delphi for PostgreSQL databases, or am I just doing something wrong with my Delphi setup?  (I did try the Delphi 64 bit binary, however I'm having issues with it not recognising the Jedi libraries that were downloaded using the GetIt manager). 

 

Any help as to the 'correct' path forward to develop PostgreSQL applications in Delphi would be greatly appreciated. :)

 

 

Share this post


Link to post

I use 64bit Exe for a FireDAC VCL program with PostgreSQL 64bit database. This connects at design time using the RAD Studio 13 64bit IDE.

(My app is C++ Builder but it is still using the FireDAC components to make the connection). Make sure you have a TFDPhysPGDriverLink component in a datamodule and that it has it's "VendorLib" property set to the full path to the libpg.dll.

 

I believe the same approach will work with the 32 bit IDE provided the VendorLib property points to a 32bit dll that  works with your database. But I never tried this as I didn't have the time/energy to rebuild a 32 bit version of the postgreSQL

drivers for the database from scratch. I am not sure about using old postgreSQL drivers (that do exist in 32 bit mode) on a later version of the database server. 

 

I think the 64bit IDE design time connection is the way to go......

  • Thanks 1

Share this post


Link to post
8 hours ago, Adam said:

I'm not sure if I'm missing a dependency.

To make sure it works, copy psql.exe into the same directory as your DLLs, and then try running it from the console.

 

Here is my old instruction on how to connect a 32-bit IDE with PostgreSQL: https://stackoverflow.com/a/58605678/6219657

Share this post


Link to post

I think the 32 bit dll you're using are too much old.

Try those: https://www.postgresql.org/ftp/odbc/releases/REL-17_00_0006/

 

You need all those 32 bit DLL in one folder:

 

Quote

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        24/02/2025     07:06        3800576 libcrypto-3.dll
-a----        24/02/2025     07:06         303616 libpq.dll
-a----        24/02/2025     07:06         625152 libssl-3.dll
-a----        24/02/2025     07:06         449640 msvcp140.dll
-a----        24/02/2025     07:06          25600 pgenlist.dll
-a----        24/02/2025     07:06         790528 pgenlist.pdb
-a----        24/02/2025     07:06          25600 pgenlista.dll
-a----        24/02/2025     07:06         790528 pgenlista.pdb
-a----        24/02/2025     07:06         571904 podbc30a.dll
-a----        24/02/2025     07:06         584192 podbc35w.dll
-a----        24/02/2025     07:06         571904 psqlodbc30a.dll
-a----        24/02/2025     07:06        2387968 psqlodbc30a.pdb
-a----        24/02/2025     07:06         584192 psqlodbc35w.dll
-a----        24/02/2025     07:06        2461696 psqlodbc35w.pdb
-a----        24/02/2025     07:06          90216 vcruntime140.dll

 

Push in your DataModule a TFDPhysPgDriverLink and SET VENDORLIB to the directory where the 32 bit dll are.

 

Now your are able to use you design components inside the IDE.

 

At runtime simply change the VENDORLIB with the correct value (where 64 bit dll are),

  • Like 1
  • Thanks 2

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

×