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