Thread: really simple example of c-code and pqlib library
Hello everybody! I'm very frustated as the examples in postgres-libpq don't work for me. If someone could present me a very simple code with connecting to database, quering few records, printing them on console and disconnecting I'd be happy. An example would be prepared for postgres 8 (standard installation) on linux (gcc) or windows(dev-cpp with mingw). Generally I'm not beginner in programming,.. anly this libpq... thank you, I'm inpatientally waiting for any help. Waldemar
On Mon, Jun 19, 2006 at 10:11:43PM +0200, Waldemar Biernacki wrote: > I'm very frustated as the examples in postgres-libpq don't work for me. How don't they work? Are you getting build errors? Runtime errors? Unexpected output? If you're getting errors then please show exactly what you did and the exact error messages. > If someone could present me a very simple code with connecting to database, > quering few records, printing them on console and disconnecting I'd be happy. The libpq documentation has examples: http://www.postgresql.org/docs/8.1/interactive/libpq.html If those are the examples you're having trouble with then we'll need to know more about what you're doing and what's happening to be able to help. -- Michael Fuhr
On Sat, Jun 24, 2006 at 10:29:27AM +0200, Waldemar Biernacki wrote: > c++ \ > -I/usr/include/postgresql \ > -I/usr/include/postgresql/libpq \ > -L/usr/lib/libpq.a \ > test.cpp -o x Check your compiler's documentation, but the -L option generally takes a directory argument, not a file. On most systems /usr/lib is searched automatically, so if that's where libpq is then you shouldn't need -L at all. To link your program against libpq use -lpq. See "Building libpq programs" for more information: http://www.postgresql.org/docs/8.1/interactive/libpq-build.html -- Michael Fuhr