pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ecpg and embedded SQL
3+ messages / 2 participants
[nested] [flat]

* ecpg and embedded SQL
@ 1998-09-03 15:53  rhayhow <rhayhow@cs.nmsu.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: rhayhow @ 1998-09-03 15:53 UTC (permalink / raw)
  To: pgsql-interfaces@hub.org

Hi,

	I am trying to compile a simple program with embedded SQL and have had
a number of problems. My goal is to get a small, simple program that
will connect to and communicate with our database before moving on to a
larger project. I am using Postgres 6.3.2 on a Solaris 2.6 machine. I am
new to Postgres and embedded SQL, so go easy on me.
	 I have read the documentation and have searched through both
mailing-list archives, and both were helpful. Unfortunately they have
not been enough to let me finish this project. I am trying to compile
Thomas Good's sample code from http://www.panix.com/~ugd/recipe.html. I
cleared out the Perl code to simplify things. Anyway, when I try to
compile using...

	#!/bin/sh
	 tput clear
	 echo -ne "Enter name of code file [ omit .pgc ]: "
	 read file
	 ecpg -o $file.c $file.pgc
	 PGBASE="/usr/local/postgresql"
	 gcc -g -I ${PGBASE}/include -I ${PGBASE}/libpq -o $file $file.c -L
${PGBASE}/lib 
	     -lecpg -lpq 

I get the following errors...

/usr/local/postgresql/lib/libpq.a(fe-connect.o): In function
`connectDB':
fe-connect.o(.text+0xf6c): undefined reference to `gethostbyname'
fe-connect.o(.text+0x10e0): undefined reference to `socket'
fe-connect.o(.text+0x116c): undefined reference to `connect'
fe-connect.o(.text+0x1218): undefined reference to `getprotobyname'
fe-connect.o(.text+0x127c): undefined reference to `setsockopt'
fe-connect.o(.text+0x12e0): undefined reference to `getsockname'

I have looked at fe-connect.o and it '#includes' two header files,
'socket.h' and 'netdb.h', that contain all of these functions. The files
'socket.h' and 'netdb.h' appear to be fine, so I don't understand what
the problem is. Is there a problem with the linking of libpq.a? Any help
would be greatly appreciated. Thanks.

Reid Hayhow
NBIF
New Mexico State University



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [INTERFACES] ecpg and embedded SQL
@ 1998-09-04 01:23  Tom Lane <tgl@sss.pgh.pa.us>
  parent: rhayhow <rhayhow@cs.nmsu.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 1998-09-04 01:23 UTC (permalink / raw)
  To: rhayhow@cs.nmsu.edu; +Cc: pgsql-interfaces@hub.org

rhayhow <rhayhow@cs.nmsu.edu> writes:
> I get the following errors...
> /usr/local/postgresql/lib/libpq.a(fe-connect.o): In function `connectDB':
> fe-connect.o(.text+0xf6c): undefined reference to `gethostbyname'
> fe-connect.o(.text+0x10e0): undefined reference to `socket'
> fe-connect.o(.text+0x116c): undefined reference to `connect'
> fe-connect.o(.text+0x1218): undefined reference to `getprotobyname'
> fe-connect.o(.text+0x127c): undefined reference to `setsockopt'
> fe-connect.o(.text+0x12e0): undefined reference to `getsockname'

On some systems, these network-related functions are not in the regular
C library, but in other libraries.  Likely you need to add "-lsocket"
or something like that to the link command.

The Postgres configure script presumably got it right, if you were able
to install a working psql.  Try looking at what the makefile for psql
is doing.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [INTERFACES] ecpg and embedded SQL
@ 1998-09-04 15:14  rhayhow <rhayhow@cs.nmsu.edu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: rhayhow @ 1998-09-04 15:14 UTC (permalink / raw)
  To: emarsden@mail.dotcom.fr, Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces@hub.org

Eric and Tom,

	Thanks a ton, adding '-lsocket' to the end of the ddb.compile did the
trick!

Reid Hayhow

---------------------------------------------------------
Eric Marsden wrote:
-snip-
> You probably need to link with the Solaris networking library
> (something like -lsocket or -lnsl, see your system's manuals).
> 
> --
> Eric Marsden


Tom Lane wrote:
-snip-
> On some systems, these network-related functions are not in the regular
> C library, but in other libraries.  Likely you need to add "-lsocket"
> or something like that to the link command.
-snip-
>                         regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1998-09-04 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-09-03 15:53 ecpg and embedded SQL rhayhow <rhayhow@cs.nmsu.edu>
1998-09-04 01:23 ` Tom Lane <tgl@sss.pgh.pa.us>
1998-09-04 15:14   ` rhayhow <rhayhow@cs.nmsu.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox