Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4MENgA81169 for ; Tue, 22 May 2001 10:23:42 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4LKvdA63223 for ; Mon, 21 May 2001 16:57:39 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f4LKuM771863 for pgsql-interfaces@postgresql.org; Mon, 21 May 2001 16:56:22 -0400 (EDT) (envelope-from news) From: "Erny" X-Newsgroups: comp.databases.postgresql.interfaces References: Subject: RE: Postgres problem Date: Mon, 21 May 2001 22:41:30 +0200 Lines: 43 X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Original-NNTP-Posting-Host: 212.166.170.72 Message-ID: <3b0980f4@news> To: pgsql-interfaces@postgresql.org X-Archive-Number: 200105/92 X-Sequence-Number: 1621 > Hello: Hi, > > I am having problem interfacing the postgres database with the > frontend(libpq),i.e using C.Database runs fine. > > PROBLEMS ARE: > 1)When compiling the C-program given in the > example for connecting the database to the > frontend using > $gcc -I /home/guest/pgsql/include test.c > > output: > /tmp/ccwWFbHo.o:In function 'exit_nicely': > /tmp/ccwWFbHo.o(.text+0x8):undefined referance to 'PQfinish' > > /tmp/ccwWFbHo.o:In function 'main': > /tmp/ccwWFbHo.o(.text+0x66):undefined referance to > 'PQsetdblogin' > > /tmp/ccwWFbHo.o(.text+0x66):undefined referance to 'PQstatus' I had the same problem. You have to include -lq on the command line. Futhermore, I had to put it on the end of the line, because the compiler collects unknown symbols first and then resolves it with the -l library switch. So I made a little Makefile like this one: #Little Makefile for making whatever source file directly to an executable. override CFLAGS += -I/usr/include/postgresql % : %.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpq % : %.c++ g++ $(CFLAGS) $(LDFLAGS) -o $@ $< -lpq++ #end Erny