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:
Show quoted text
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 -lpqGood 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.soresponde
/usr/bin/ld: cannot open -llibpg.so : no such file or directory
collect2: ld returned 1 exit statusI 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
Show quoted text
Thanks for yor help.
From: guy@pop.incentre.net
To: pgsql-general-digest@hub.org
Date: Thu, 12 Aug 1999 16:30:34 %z (MDT)
Subject: Re: [GENERAL] Problem with compiled C
..
To compile C programs you need to add the pq library, so use something like:
gcc -o test test.c -lpqGood 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".
..
So when I compiled my program in C use
gcc -o prueba prueba.c -llibpq.soresponde
/usr/bin/ld: cannot open -llibpg.so : no such file or directory
collect2: ld returned 1 exit statusI probe with
gcc -o prueba prueba.c -llibpq.so -L/usr/libBut 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
Hi
If you have not already tried;
edit /etc/ld.so.conf
add the location of libpq.so {maybe it is /opt/pgsql/lib}to new line at
the bottom of the file.
Then run ldconfig, this will reconfigure ld to use the new directory as a
as well as the others in the list for dynamicly linked libraries.
When you specify a library with the CC -lxxx, you do not include the extension
or the "lib" prefix. {use -lpg for libpg.so}
You will also need to include some additional headers
example from "funcs.c" {}:
#include <postgres.h> /* for char16, etc. */
#include <utils/palloc.h> /* for palloc */
#include <libpq-fe.h> /* for TUPPLE, required for most programs */
#include <executor/executor.h> /* for GetAttributeByName() */
You will need to add an include directory directive on the cc prompt.
example
cc -o test -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpg -c test.c
This will compile an executable program {test}, to compile an object file use :
cc -O -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpg -c test.c
This will create an object file {test.o}
This should allow the complilation to work, the -L/usr/local/pgsql/lib may not
be nessary, if /etc/ld.so.conf is setup and ldconfig has been run, but I can't
remember for sure.
This is what I use when I write utilities to directly access postgresql.
I have not yet written any C functions, but it should work the same way.
In the source for postgresql there are some examples. The source for funcs.c
is in the source tree, and the procedures in it are documented in the
programmers reference. This file has three or more examples of C functions.
Good Luck
Import Notes
Resolved by subject fallback
..
To compile C programs you need to add the pq library, so use something like:
gcc -o test test.c -lpqGood 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".
..
So when I compiled my program in C use
gcc -o prueba prueba.c -llibpq.soresponde
/usr/bin/ld: cannot open -llibpg.so : no such file or directory
collect2: ld returned 1 exit statusI probe with
gcc -o prueba prueba.c -llibpq.so -L/usr/libBut 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
Hi
If you have not already tried;
edit /etc/ld.so.conf
add the location of libpq.so {maybe it is /opt/pgsql/lib}to new line at
the bottom of the file.
Then run ldconfig, this will reconfigure ld to use the new directory as a
as well as the others in the list for dynamicly linked libraries.
When you specify a library with the CC -lxxx, you do not include the extension
or the "lib" prefix. {use -lpg for libpg.so}
You will also need to include some additional headers
example from "funcs.c" {}:
#include <postgres.h> /* for char16, etc. */
#include <utils/palloc.h> /* for palloc */
#include <libpq-fe.h> /* for TUPPLE, required for most programs */
#include <executor/executor.h> /* for GetAttributeByName() */
You will need to add an include directory directive on the cc prompt.
example
cc -o test -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpg -c test.c
This will compile an executable program {test}, to compile an object file use :
cc -O -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpg -c test.c
This will create an object file {test.o}
This should allow the complilation to work, the -L/usr/local/pgsql/lib may not
be nessary, if /etc/ld.so.conf is setup and ldconfig has been run, but I can't
remember for sure.
This is what I use when I write utilities to directly access postgresql.
I have not yet written any C functions, but it should work the same way.
In the source for postgresql there are some examples. The source for funcs.c
is in the source tree, and the procedures in it are documented in the
programmers reference. This file has three or more examples of C functions.
Good Luck
Import Notes
Resolved by subject fallback