Recent

Author Topic: Postgres Cannot connect  (Read 11044 times)

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #15 on: November 22, 2011, 07:06:09 pm »
Quote
What version of Postgres are you using?
pgAdmin v1.14 from http://www.pgadmin.org/download/macosx.php. The Postgres  database is on another server and the version is not relevant to this problem. On OSX I only have pgAdmin3.
To find the location of the libpq library used by pgAdmin run
Code: [Select]
otool -L /path to pgA2dmin3/pgAdmin3.App/COntents/MacOS/pgAdmin3 | grep libpqI found the bug in TPQConnection. In packages\postgres\src\dllistdyn.pp the library is hard coded to libpq.so. I'll create a bug report with a patch.
In the mean time, creating the symlink libpq.so solves this problem.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #16 on: November 22, 2011, 07:08:48 pm »
Awesome! Is this an easy fix I can apply to my code base now?

I downloaded the new version and did the link stuff but that didnt seem to do much for fixing my issue? I noticed that if I dbl click the file in the /usr/lib/ it says the alias is broken, but I assume it shouldnt be?

Thanks,

Tom

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #17 on: November 22, 2011, 07:14:21 pm »
Using that cmd to find what lib pgadmin uses gives me this:


Tom-Russells-MacBook-Pro:~ Tom$ otool -L /path to pgA2dmin3/pgAdmin3.App/COntents/MacOS/pgAdmin3 | grep libpq
otool: can't open file: /path (No such file or directory)
otool: can't open file: to (No such file or directory)
otool: can't open file: pgA2dmin3/pgAdmin3.App/COntents/MacOS/pgAdmin3 (No such file or directory)

Does this mean my install is bad or something?

Thanks,

Tom

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #18 on: November 22, 2011, 07:21:02 pm »
Quote
Does this mean my install is bad or something?
No. That means that you have to replace "/path to pgA2dmin3/" with the path where you installed pgAdmin3. For me this is /Applications/pgAdmin3.App/COntents/MacOS/pgAdmin3.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #19 on: November 22, 2011, 07:33:12 pm »
At least I got some output:


/Applications/pgAdmin3.app/Contents/MacOS/pgAdmin3 (architecture i386):
   /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 5.0.0)
   /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
   /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
   /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)
   /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 1327.73.0)
   /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
   /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_stc-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_richtext-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_aui-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_xrc-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_qa-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_html-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_adv-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_core-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_base_carbonu_xml-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_base_carbonu_net-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_base_carbonu-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libxml2.2.dylib (compatibility version 10.0.0, current version 10.1.0)
   /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
   /usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version 5.0.0)
   @executable_path/../../Contents/Frameworks/libxslt.1.dylib (compatibility version 3.0.0, current version 3.23.0)
   @executable_path/../../Contents/Frameworks/libpq.5.dylib (compatibility version 5.0.0, current version 5.4.0)
   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
   /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Applications/pgAdmin3.app/Contents/MacOS/pgAdmin3 (architecture ppc):
   /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 5.0.0)
   /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
   /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
   /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)
   /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 1327.73.0)
   /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
   /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_stc-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_richtext-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_aui-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_xrc-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_qa-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_html-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_adv-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_macu_core-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_base_carbonu_xml-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_base_carbonu_net-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libwx_base_carbonu-2.8.0.dylib (compatibility version 9.0.0, current version 9.0.0)
   @executable_path/../../Contents/Frameworks/libxml2.2.dylib (compatibility version 10.0.0, current version 10.1.0)
   /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
   /usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version 5.0.0)
   @executable_path/../../Contents/Frameworks/libxslt.1.dylib (compatibility version 3.0.0, current version 3.23.0)
   @executable_path/../../Contents/Frameworks/libpq.5.dylib (compatibility version 5.0.0, current version 5.4.0)
   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
   /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #20 on: November 22, 2011, 07:39:59 pm »
Good   :)
Quote
/Applications/pgAdmin3.app/Contents/MacOS/pgAdmin3
Your pgAdmin3 is installed in the same location as on my machine.
Quote
@executable_path/../../Contents/Frameworks/libpq.5.dylib
and libpq.5.dylib  is in the same place. This means you can run the 2 lines I gave you before:
Code: [Select]
sudo ln -s /Applications/pqAdmin3.app/Contents/Frameworks/libpq.5.dylib /usr/lib/libpq.dylib
sudo ln -s /usr/lib/libpq.dylib /usr/lib/libpq.so
This should solve your problem.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #21 on: November 22, 2011, 07:44:09 pm »
Something is amiss for me cause those 2 lines I just tried and it still says that it cannot find the libpq.dylib.

I am trying to connect it via design time though.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #22 on: November 22, 2011, 07:49:19 pm »
What is
Code: [Select]
ls -l /usr/lib/libpq.*returning?
Quote
I am trying to connect it via design time though.
That is fine. For me that works perfect.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #23 on: November 22, 2011, 08:37:08 pm »
lrwxr-xr-x  1 root  wheel  60 Nov 22 13:42 /usr/lib/libpq.dylib -> /Applications/pqAdmin3.app/Contents/Frameworks/libpq.5.dylib
lrwxr-xr-x  1 root  wheel  20 Nov 22 13:42 /usr/lib/libpq.so -> /usr/lib/libpq.dylib


Thats what it returns.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #24 on: November 22, 2011, 09:20:39 pm »
That is what it should be.
So there is something else missing or wrong. In the mean time, I guess you have tried already a lot of things. Possibly there is some conflicting stuff now.
Can you do the following:
In lazarus, start new application, drop Tpqconnection on the form, in form.oncreate enter
Code: [Select]
PQConnection1.connected:=true;, save as project1, build, run. It will say "libpq.dylib not found". In a terminal window, cd to the directory containing your new project1 and run
Code: [Select]
sudo dtruss project1.app/Contents/MacOS/project1 &> dtruss.out Click terminate on the window "libpq.dylib not found". This will create the file dtruss.out in your current directory. If you are courageous, open the file in an editor and look for libpq.dylib. It will show the different paths used to find the library and, if it finds the library, show the dependencies it tries to open. If you prefer you can also attach the file to your next post  ;)

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #25 on: November 22, 2011, 09:35:54 pm »
This is the main part of the output that pertains to my issue:

stat64("libpq.dylib\0", 0xBFFFEC4C, 0x3)       = -1 Err#2
stat64("/Users/Tom/lib/libpq.dylib\0", 0xBFFFF03C, 0x3)       = -1 Err#2
stat64("/usr/local/lib/libpq.dylib\0", 0xBFFFF03C, 0x3)       = -1 Err#2
stat64("/usr/lib/libpq.dylib\0", 0xBFFFF03C, 0x3)       = -1 Err#2

Thanks,

Tom

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #26 on: November 22, 2011, 09:56:53 pm »
AHA! Now we are getting somewhere. It looks like you are trying to use a 32 bit dylib with a 64 bit program.
Do
Code: [Select]
file /usr/lib/libpq.dylib
file project1.app/Contents/MacOS/project1
Probably you get Mach-O executable i386 for the first and Mach-O 64-bit for the second.
If that is the case compile for 32 bit or use a 64 bit libpq.dylib. There is a 64 bit client available here http://www.kyngchaos.com/software:postgres


tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #27 on: November 22, 2011, 10:09:15 pm »
Weird but this is what I get:


file /usr/lib/libpq.dylib
/usr/lib/libpq.dylib: broken symbolic link to /Applications/pqAdmin3.app/Contents/Frameworks/libpq.5.dylib
Tom-Russells-MacBook-Pro:LazTestNate Tom$ file project1.app/Contents/MacOS/project1
project1.app/Contents/MacOS/project1: Mach-O executable i386




ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #28 on: November 22, 2011, 10:36:28 pm »
Quote
sudo ln -s /Applications/pqAdmin3.app/Contents/Frameworks/libpq.5.dylib /usr/lib/libpq.dylib
There is a typo. This should be
Code: [Select]
sudo ln -s /Applications/pgAdmin3.app/Contents/Frameworks/libpq.5.dylib /usr/lib/libpq.dylibpgAdmin3 instead of pqAdmin3  %)
That explains your broken link.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #29 on: November 22, 2011, 10:54:36 pm »
OMG, that works. Finally it works!!! Thanks sooooo much.

SO at least this works for now until they accept the patch for the one file then?

Thanks,

Tom