Recent

Author Topic: Postgres Cannot connect  (Read 11041 times)

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Postgres Cannot connect
« on: November 21, 2011, 02:46:03 pm »
Hi,

I am trying to connect to a postgres db on Mac OSX Snow Leopard. When I set connection to true in the design part it says it cannot find libpq.dylib. It is installed correctly and I can use the db with PgAdmin but i am at a loss as to why it will not find the correct files to load the db.

Any Ideas on how to fix this?

Thanks,

Tom

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #1 on: November 21, 2011, 04:00:37 pm »
I am assuming there is a way to set the path to where the postgres libs reside so that it is known to lazarus or something but am not sure where that would be set? I did add the path to my compiler options but that doesnt seem to work either.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #2 on: November 21, 2011, 04:23:40 pm »
The DYLD_LIBRARY_PATH environment variable is used to find libraries. on Mac OSX.
In Lazarus go to Run / Run Parameters / Environment tab and check or add the environment variable.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #3 on: November 21, 2011, 05:22:49 pm »
I added these items but that doesnt seem to work either.

Any other ideas as to what I would need to do?

Thanks,

Tom

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #4 on: November 21, 2011, 09:42:12 pm »
Does anyone have any ideas as to resolve this? I just need to simply connect to the postgre server, it should'nt be this hard should it?

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #5 on: November 21, 2011, 10:56:07 pm »
Is there a way to set the path to which the libs are for the connection?

cpalx

  • Hero Member
  • *****
  • Posts: 619
Re: Postgres Cannot connect
« Reply #6 on: November 22, 2011, 02:36:29 am »
install pgadmin3, then search the file libpq.dylib and copy in /usr/lib

works perfect for me.

I use zeoslib and i had to do something else. simbolic link libpq.so -> libpq.dylib

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #7 on: November 22, 2011, 12:06:50 pm »
So I should be able to put the dylib link in usr/lib? Also how do you set a symbolic link in osx like you were saying?

Thanks,

Tom

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #8 on: November 22, 2011, 12:11:44 pm »
I just tried copying in that file to usr/lib and that didnt work either. I am assuming I need to set a symbolic link then. I did see in the unit it looks for .so instead of the dylib.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Postgres Cannot connect
« Reply #9 on: November 22, 2011, 02:04:17 pm »
Don't know if such a tool exists for OSX, but for Solaris/Linux you have the strace tool, that can show all file access - might help if you're totally stuck otherwise

This http://stackoverflow.com/questions/3007868/how-can-get-dtrace-to-run-the-traced-command-with-non-root-priviledges) seems to say something like:
Code: [Select]
sudo dtruss -f su -l whoami cd pwd && <insertlazarusstartupcommandhere>
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

cpalx

  • Hero Member
  • *****
  • Posts: 619
Re: Postgres Cannot connect
« Reply #10 on: November 22, 2011, 02:13:38 pm »

sudo -i   # <write your password>
cd /usr/lib
ln libpq.dylib  libpq.so

that works fine for me.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Postgres Cannot connect
« Reply #11 on: November 22, 2011, 02:19:58 pm »
If that works, anybody else think a patch to make the postgresql connector work for OSX is in order?!?!?  :)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #12 on: November 22, 2011, 02:32:51 pm »
Man I must be having lousy luck cause that didnt work for me either.

Should I be using the zeos db stuff rather than pqconnection?

Thanks,

Tom

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Postgres Cannot connect
« Reply #13 on: November 22, 2011, 06:35:55 pm »
Quote
ln libpq.dylib  libpq.so
I had to do a
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
to get TPQConnection working.  pqAdmin3 is installed in the  /Applications directory. A dtruss showed that the program first opens libpq.dylib and then libpq.so  :o
Quote
If that works, anybody else think a patch to make the postgresql connector work for OSX is in order?!?!?  :)
I'm re-building fpc with debug info to find where the libpq.so is called. But yes, this has all the looks of a bug.
Quote
Should I be using the zeos db stuff rather than pqconnection?
Zeos doesn't support OSX :(

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Re: Postgres Cannot connect
« Reply #14 on: November 22, 2011, 06:49:56 pm »
Ok so I tried that but the really odd part is that my pgadmin3 does not have a frameworks folder in it? I can't link to that app cause I do not have anything in the contents like you show here.

What version of Postgres are you using?

Thanks,

Tom