Обсуждение: Problem with compiled C
Hi , I have two problems.
1. When a use pgacces, i try connect with one database, responde the
next error.
Error trying to connect to database "xxxx" on host "xxx"
PostgreSQL error message: Connection to database failed
connectDB() --connect() failed: Connection refused Is the postmaster
running (whit -i) at "xxx" and accepting connections on TCP/IP por
"5432".
I use Postgresql 6.5, on RedHat 6. I don't know why not connect.
2. When i compiled one program in C, I don't Know what parameter i use
with gcc
but i compilied the example of the testc.c in manual of programmer no
indicate How to compiled.
Thanks for yor help.
From an xterm / command prompt, type: ps auxw |grep postmaster Make sure the postmaster is running with the -i option (ie, postmaster -i -B 256) If you are running pgaccess on a different machine than PostGres is running on, you'll also have to edit the pg_hba.conf to make sure you are allowed to connect from the remote machine. To compile C programs you need to add the pq library, so use something like: gcc -o test test.c -lpq Good luck. At 04:24 PM 8/11/99, Héctor Morales wrote: >Hi , I have two problems. > >1. When a use pgacces, i try connect with one database, responde the >next error. > Error trying to connect to database "xxxx" on host "xxx" > PostgreSQL error message: Connection to database failed >connectDB() --connect() failed: Connection refused Is the postmaster >running (whit -i) at "xxx" and accepting connections on TCP/IP por >"5432". > > I use Postgresql 6.5, on RedHat 6. I don't know why not connect. > >2. When i compiled one program in C, I don't Know what parameter i use >with gcc >but i compilied the example of the testc.c in manual of programmer no >indicate How to compiled. > > >Thanks for yor help. > > >
Charles Tassell wrote:
> >From an xterm / command prompt, type:
>
> ps auxw |grep postmaster
>
> Make sure the postmaster is running with the -i option (ie, postmaster -i
> -B 256) If you are running pgaccess on a different machine than PostGres is
> running on, you'll also have to edit the pg_hba.conf to make sure you are
> allowed to connect from the remote machine.
>
> To compile C programs you need to add the pq library, so use something like:
> gcc -o test test.c -lpq
>
> Good luck.
>
> At 04:24 PM 8/11/99, Héctor Morales wrote:
> >Hi , I have two problems.
> >
> >1. When a use pgacces, i try connect with one database, responde the
> >next error.
> > Error trying to connect to database "xxxx" on host "xxx"
> > PostgreSQL error message: Connection to database failed
> >connectDB() --connect() failed: Connection refused Is the postmaster
> >running (whit -i) at "xxx" and accepting connections on TCP/IP por
> >"5432".
> >
> > I use Postgresql 6.5, on RedHat 6. I don't know why not connect.
> >
> >2. When i compiled one program in C, I don't Know what parameter i use
> >with gcc
> >but i compilied the example of the testc.c in manual of programmer no
> >indicate How to compiled.
> >
> >
> >Thanks for yor help.
> >
> >
> >
Excellent pgaccess work is great.
So when I compiled my program in C use
gcc -o prueba prueba.c -llibpq.so
responde
/usr/bin/ld: cannot open -llibpg.so : no such file or directory
collect2: ld returned 1 exit status
I probe with
gcc -o prueba prueba.c -llibpq.so -L/usr/lib
But equal , I sure that the library is in this directory and a observe the
LD_LIBRARY_PATH and the directory is in this variable.
So i don't Know why not compiled.
Thanks
On Wed, 11 Aug 1999, [iso-8859-1] H�ctor Morales wrote: > Charles Tassell wrote: > >[SNIP] > > To compile C programs you need to add the pq library, so use something like: > > gcc -o test test.c -lpq > [SNIP] > Excellent pgaccess work is great. > > So when I compiled my program in C use > gcc -o prueba prueba.c -llibpq.so > > responde > /usr/bin/ld: cannot open -llibpg.so : no such file or directory > collect2: ld returned 1 exit status > > I probe with > gcc -o prueba prueba.c -llibpq.so -L/usr/lib gcc -o prueba prueba.c -L/usr/lib -lpq -l tells gcc ( the linker, actually ) to look for lib<whatever follows the -l>. ie: -lm == libm, -lpq == libpq. -llibpq.so == liblibpq.so. obviously that file doesnt exist. more information can be obtained via 'info gcc' or 'man gcc'. --- Howie <caffeine@toodarkpark.org> URL: http://www.toodarkpark.org "The distance between insanity and genius is measured only by success."
> Hi , I have two problems. > > 1. When a use pgacces, i try connect with one database, responde the > next error. > Error trying to connect to database "xxxx" on host "xxx" > PostgreSQL error message: Connection to database failed > connectDB() --connect() failed: Connection refused Is the postmaster > running (whit -i) at "xxx" and accepting connections on TCP/IP por > "5432". > You must launch postmaster with parameters -S -i, if you have a postgres file in /etc/rc.d/init.d/ open it, and modify how postgres is started > I use Postgresql 6.5, on RedHat 6. I don't know why not connect. > > 2. When i compiled one program in C, I don't Know what parameter i use > with gcc > but i compilied the example of the testc.c in manual of programmer no > indicate How to compiled. > You must compile with -lpq , something like gcc test.c -lpq > > Thanks for yor help. > > >