Trouble linking to libpq

From: "Nathan S(dot)" <gblues97206(at)yahoo(dot)com>
To: PostgreSQL-Cygwin Mailing List <pgsql-cygwin(at)postgresql(dot)org>
Subject: Trouble linking to libpq
Date: 2003-08-11 02:08:14
Message-ID: 20030811020814.32893.qmail@web40111.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-cygwin

Greetings,

I am writing a Multi-User Dungeon (MUD) codebase that will be pulling
its object information from a postgres database. I am interfacing with
the database via libpq.

The problem I am having is that I cannot link to libpq, and I cannot
figure out why.

The following snippet compiles and links fine by itself:

--- begin ---
#include <stdio.h>
#include <libpq-fe.h>

int main(int argc, char **argv)
{
PGconn *conn;

conn = PQconnectdb("");
return 0;
}
--- end ---
(compiler commandline for above: gcc test.c -o test -lpq)
However, if I take the same snippet and try to link it along with other
files in my project, here's the error I get:

--- begin ---
gcc -o test -lpq main.o string.o memory.o network.o event.o command.o
player.o tables.o lookup.o db.o
db.o(.text+0x10f):db.c: undefined reference to `_PQconnectdb'
collect2: ld returned 1 exit status
make: *** [test] Error 1
--- end ---

And, for good measure, here's my Makefile:
--- begin ----
O_FILES=main.o string.o memory.o network.o event.o command.o player.o
tables.o lookup.o db.o
L_FLAGS=-lpq
C_FLAGS=

EXE=test

$(EXE): $(O_FILES)
gcc -o test $(L_FLAGS) $(O_FILES)
.c.o:
gcc $(C_FLAGS) -c $(C_FLAGS) $<
clean:
rm -f $(EXE) $(O_FILES)
--- end ---

Cygwin is the newest 1.3.x release and the postgres package is 7.3.4-1.

Any suggestions?

Nathan

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Browse pgsql-cygwin by date

  From Date Subject
Next Message Claudio Natoli 2003-08-11 02:22:02 Re: Trouble linking to libpq
Previous Message Xinyu Hua 2003-08-09 22:57:42 less: not found