Working with PostgreSQL in LAN

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

Client dll dependencies have been slightly changed recently, not sure in what version (probably it was 8.3.1), but 8.3.6, I beleive, have same dll dependecies as 8.3.7. Here it is:
  • comerr32.dll
    gssapi32.dll
    k5sprt32.dll
    krb5_32.dll
    libeay32.dll
    libiconv-2.dll
    libintl-8.dll
    libpq.dll
    msvcr71.dll
    ssleay32.dll
It's best to pick up this dlls from postgres\bin directory, except msvcr71.dll. You wont need it on >= WinXP client machines.

And some tips for Inno setup.
- avoid storing dlls in windows\system32 dir. Put it in you app directory and be sure that applications working directory is properly set in app shortcut or code (see MS SDK, SetDllDirectory function).This will save you a lot of problems (and sleepless nights in my case).
Here is why:
On some client machines I found ssleay32.dll and libeay32.dll with ridiculously high version numbers (Don't now who distribute this and in which application, but author probably want to be sure that HIS dll will always be installed). This prevents correctly written installer to install effectively newer versions of this dll's (but with smaller version numbers). Those dlls are loaded indirectly (libpq tries to load them while your app loads libpq) and, if they are too old with some functions missing, libpq "breaks". From application point of view - libpq can't be loaded/found!

- keep in mind that library search path was changed in win2k (see MS SDK Dynamic-Link Library Search Order or SafeDllSearchMode )

- if still wont work - help yourself with MS Dependency Walker utility (comes in resource kit) and/or sysinternals process expored.

- if you want database accessible from other hosts in lan, dont forget to chage pg_hba.conf and allow that. This can be easily automated in Inno setup.

- WinXP SP2 or WinXP sp3 - doesn't really matter in this case.
Khaoz
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.04.2009, 21:01

Post by Khaoz »

trupka wrote:Client dll dependencies have been slightly changed recently, not sure in what version (probably it was 8.3.1), but 8.3.6, I beleive, have same dll dependecies as 8.3.7. Here it is:
  • comerr32.dll
    gssapi32.dll
    k5sprt32.dll
    krb5_32.dll
    libeay32.dll
    libiconv-2.dll
    libintl-8.dll
    libpq.dll
    msvcr71.dll
    ssleay32.dll
It's best to pick up this dlls from postgres\bin directory, except msvcr71.dll. You wont need it on >= WinXP client machines.
The dll list which i'm using is like yours, so i'm in the right way :)
trupka wrote: And some tips for Inno setup.
- avoid storing dlls in windows\system32 dir. Put it in you app directory and be sure that applications working directory is properly set in app shortcut or code (see MS SDK, SetDllDirectory function).This will save you a lot of problems (and sleepless nights in my case).
Here is why:
On some client machines I found ssleay32.dll and libeay32.dll with ridiculously high version numbers (Don't now who distribute this and in which application, but author probably want to be sure that HIS dll will always be installed). This prevents correctly written installer to install effectively newer versions of this dll's (but with smaller version numbers). Those dlls are loaded indirectly (libpq tries to load them while your app loads libpq) and, if they are too old with some functions missing, libpq "breaks". From application point of view - libpq can't be loaded/found!
I have searched for all dll's before install my application, so dll version can't be a problem. Anyway, i have changed the dll installation to go to the app directory .. without success.
trupka wrote: - keep in mind that library search path was changed in win2k (see MS SDK Dynamic-Link Library Search Order or SafeDllSearchMode )
Ok, here's the link which i'm reading and with SafeDlLSearchMode enabled or disabled, the first place where windows will look for the needed dll's is the app directory, and as i said before, i have changed the dll installation to the app directory but the error persist.
trupka wrote: - if still wont work - help yourself with MS Dependency Walker utility (comes in resource kit) and/or sysinternals process expored.
Let's google about this utility and learn to use.
trupka wrote: - if you want database accessible from other hosts in lan, dont forget to chage pg_hba.conf and allow that. This can be easily automated in Inno setup.
Ok. i'm used to use postgresql with python in a lan so it's the first thing which i do :D
trupka wrote: - WinXP SP2 or WinXP sp3 - doesn't really matter in this case.
You're right and i'm in trouble :(
Last edited by Khaoz on 30.04.2009, 01:06, edited 1 time in total.
Khaoz
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.04.2009, 21:01

Post by Khaoz »

O... just to add 2 more complications:

1) My client has another pc with vista and my app works fine. If i plug my notebook (also with vista) my application works fine.
2) Here at home, i have a windows xp which my wife uses and she is working on my app with my notebook as server while i'm writing this post. :wallb: :wallb: :wallb:
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

Khaoz
It seems that you have some DLL dependency problem "inside" libpq.
This is hard to resolve but, if you don't need ssl/international support and other fancy stuff, you can take postgresql source and recompile libpq.dll without it. You will get "your own" and much smaller libpq.dll without dll dependencies that will work on almost any system (but without additonal features like ssl suport).

Just cross my mind - did you try "loadlibrary('libpq.dll')" in plain VCL app (without zeos), just to see what happens?
Khaoz
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.04.2009, 21:01

Post by Khaoz »

LoadLibrary works just fine.
I have created a simple application with a button with just loadlibrary and everything was a success.
So i have tried to use loadlibrary in my data module OnCreate but, after load libpq.dll connect does raise the same exception.
Khaoz
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.04.2009, 21:01

Post by Khaoz »

Errr... sry. LoadLibrary does not work. I was just calling LoadLibrary, but i need to assign the result to a handle and check if it is different of zero.

/me are owned by a windows xp.

Let's as to the client to use vista. :/
Khaoz
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.04.2009, 21:01

Post by Khaoz »

Using postgresql one click installer, my app started to work. So, to test if was the installation or what, i removed the postgresql and... my app still does work.

Seems to be something with Visual C++ 2005 Redistributable. After removed this, my app stoped.

But i have tried to re-install vc 2005 manually and can't get my app to work again. I will try to understad what postgresql installation does to fix my problem with vc 2005.
Khaoz
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.04.2009, 21:01

Post by Khaoz »

And DONE!!!!!

The problem IS with the Microsoft Visual C++ 2005 Redistributable Package (x86) but you the need the one with SP1. The correct package is:

Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)

Downloaded at:

http://www.microsoft.com/downloads/deta ... layLang=en

You can find some nice infos here:

http://pgolub.wordpress.com/

Ty for your help trupka.
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

You're welcome :)
I saw a lot dll problems with postgres, (mostly caused by third-party libs) but never encounter something like this. Your discovery is valuable for everyone who works with pgsql@win. Thank you for charting new territories in DLL-HELL.
Post Reply