Page 1 of 2

[solved] ZConnection.libraryLocation

Posted: 11.06.2012, 04:31
by elidorio2
Hello

I'm compiling my executable application developed with Zeos 7 and Lazarus 09.30.4 and Postgresql 9.1 and Windows7 32.
And the same libpq81.dll not find the dll, the dll is already in the same directory as the executable and yet the message remains.
The message:
None of the dynamic libraries Can Be found or is not loadable: libpq81.dll libpq.dll!
Use TZConnection.libraryLocation if the location is invalid.


What can be?

Edson

Posted: 11.06.2012, 07:40
by EgonHugeist
Edson,

this may be a stupid question: Different compilete versions in 32/64Bit? And one of the unsupported dll's was found in the Path environment? A 64Bit exe can not load a 32Bit dll header or reverted as far as i know...

I do not see another possibility to get this exception if the files do exist.

Michael

Posted: 11.06.2012, 14:41
by elidorio2
Michael.

Just a correction.
Exe was compiled on a machine with windows7 32. I'm trying to run the exe on a machine with windows xp 32, such that it has problems with the dll.

Edson

Posted: 11.06.2012, 15:04
by EgonHugeist
Ok Edson. We start from the premise that you've a 32Bit Application and 32Bit dll.

Are all dll's of PostgreSQL avaiable in that directory? Not only the libpg.dll?

Michael

Posted: 11.06.2012, 17:00
by elidorio2
The dll Postgresql are all in the directory. As the picture below.
In ZComnection.LibraryLocation need to configure something?

Edson

Posted: 11.06.2012, 17:52
by ism
Spaces in path ?
Or non ascii symbols in path

Or ./directory

Or LibraryLocation must be empty , then it will search the current directory

Posted: 11.06.2012, 22:39
by EgonHugeist
elidorio2,

my first advice clean up that folder. Keep only the librarys you need (copy them from the PostgreSQL\Bin folder). And i join with ism here. In your case use TZLibraryLocation = ''; because the system finds th dll's in your application folder. Also be sure you do not have another version in the Windows\system directory.

That exception will only be raised if the function LoadLibrary does not return a valid handle or the dll is realy not found. These are the two possibilities and nothing else is possible.

Michael

Posted: 12.06.2012, 00:36
by elidorio2
Hello Michel and Ism,
There must be something strange, since I cleaned the whole directory and the message still persists. I turned off all the dll and I was asking as putting and yet the error persists.

Posted: 12.06.2012, 05:26
by EgonHugeist
elidorio2,

Ok step by step, Edson. Tell me do you use the TZConnection.LibraryLocation ? Is that property empty?

Michael

Posted: 12.06.2012, 15:46
by elidorio2
Michael,
I do not use it.
I do not set any value in this property is empty.

Posted: 12.06.2012, 20:03
by ism
The simple question is whether directory with the dll the current?
Try to check temporarily put in C: \ windows \ system32

Check start shortcut

Posted: 13.06.2012, 01:42
by elidorio2
Hello Michael,

The dll files are todoas in the current directory. Strange all the dll are in the directory and it is asking for libpq and libpq81.
I moved all the dll to the system32 and even then, and still the problem pesiste. I've been searching on google and found several people with the same problem, the solution is not encotrei yet!
Note, I'm using postgresql 9.1.
Please if possible do a test there, create an exe and try to run it on another machine.

Edson

Posted: 13.06.2012, 07:04
by EgonHugeist
elidorio2,

Hmm curious. Edson you bo not need the libpq81.dll the libpq.dll from the PostgreSQL\Bin folder should be enough.

Edson please scan that Harddisk for additional available libpg*.dll. I've tested this (not with XP) and it works. Check the path= environment variable (Start\control-panel\...).

I'm still thinking that your app and that dll is incompatible. Test it by your self:
Open ZPlainLoader.pas

Code: Select all

function TZNativeLibraryLoader.ZLoadLibrary(Location: String): Boolean;
begin
   if FLoaded then
      Self.FreeNativeLibrary;
   FLoaded := False;
   Result := False;

{$IFDEF UNIX}
  {$IFDEF FPC}
        FHandle := LoadLibrary(PAnsiChar(Location));
  {$ELSE}
        FHandle := HMODULE(dlopen(PAnsiChar(Location), RTLD_GLOBAL));
  {$ENDIF}
{$ELSE}
        FHandle := LoadLibrary(PChar(Location));
{$ENDIF}

   if (FHandle <> INVALID_HANDLE_VALUE) and (FHandle <> 0) then
   begin
      FLoaded := True;
      FCurrentLocation := Location;
      Result := True;
   end;
end;
Add there a line for fileexist(Location) or an errormessage which will be raised if the Handle is invalid..

Michael

Posted: 13.06.2012, 17:05
by elidorio2
Hello Michael,

What's to understand is that Zeos does not read the other directory unless the C: \ Program Files \ PostgreSQL \ 9.1 \ bin.

In my opinion he is trying to get the dll in the directory above.

On my development computer it finds the dll normal, because they are in the directory above, now when I change the exe to another computer he can not find something that dll.

Posted: 13.06.2012, 18:14
by miab3
Today I installed PostgreSQL 9.1.4-64 bits.
Everything works fine on D2006, DXE232/64, and Lazarus Win 32/64.
On the server and three computers Win7 32/64, Win 7 32 and Vista 32 after installing the appropriate client libraries to the appropriate system directories or in the application directory.

Zeos 7 testing-egonhugeist rev.1389

Michal Abramczyk