Re: [GENERAL] connecting using libpq breaks printf

2009-02-20 Thread Albe Laurenz
Joey Morris wrote: > This is my first attempt at using libpq, and I'm running across a strange > problem. Here is my bare-bones program: > > #include > #include "libpq-fe.h" > > int main(int argc, char **argv) { > PGconn *conn; > fprintf(stderr, "connecting\n"); > conn = PQconnectdb("dbnam

[GENERAL] connecting using libpq breaks printf

2009-02-19 Thread Joey Morris
This is my first attempt at using libpq, and I'm running across a strange problem. Here is my bare-bones program: #include #include "libpq-fe.h" int main(int argc, char **argv) { PGconn *conn; fprintf(stderr, "connecting\n"); conn = PQconnectdb("dbname=postgres"); PQfinish(conn); retur

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Joey Morris
Aurimas Černius wrote on Wed, Feb 18, 2009 at 05:01:14PM +0200: > Did you use *exactly* the same command line to compile both versions? > What is that command line(s)? Yes, I used the same compilation command line for both versions: gcc -o pq_test -I"C:\Program Files\PostgreSQL\8.3\include" -L"

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Joey Morris
> How do you run the program, in console or by double clicking on > executable. Try the second. Does the console window apear on the screen? Aha! This tip has led to the solution. I had been running the program from an emacs shell buffer. If I run it from the Windows console or by double-clickin

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Mikko Partio
On Wed, Feb 18, 2009 at 4:47 PM, Joey Morris wrote: > This is my first attempt at using libpq, and I'm running across a strange > problem. Here is my bare-bones program: > > #include > #include "libpq-fe.h" > > int main(int argc, char **argv) { > PGconn *conn; > fprintf(stderr, "connecting\n")

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Sam Mason
On Wed, Feb 18, 2009 at 06:08:07PM +0200, Aurimas Cernius wrote: > Joey Morris wrote: > > gcc -o pq_test -I"C:\Program Files\PostgreSQL\8.3\include" -L"C:\Program > > Files\PostgreSQL\8.3\lib" -lpq pq_test.c gcc won't give many warnings unless you give it a -Wall flag; it may be doing strange thi

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Joey Morris
David Wilson wrote on Wed, Feb 18, 2009 at 11:36:44AM -0500: > Try adding "fflush(stderr);" after your fprintf() call. If the > connection is hanging and output hasn't been flushed, you wouldn't see > much. No, this doesn't help, either. Thanks for the suggestion. -- Sent via pgsql-general mai

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread David Wilson
On Wed, Feb 18, 2009 at 9:47 AM, Joey Morris wrote: > I expected this program to print "connecting", but in fact I get no output > whatsoever. If I comment out the PQconnectdb and PQfinish lines, I see > "connecting" as expected. What could be going on here? Try adding "fflush(stderr);" after yo

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Aurimas Černius
Hi, Aurimas Černius wrote on Wed, Feb 18, 2009 at 06:08:07PM +0200: Libraries should be places after the source file, that is (not sure about -L, but for -l surely): gcc -o pq_test -I"C:\Program Files\PostgreSQL\8.3\include" pq_test.c -L"C:\Program Files\PostgreSQL\8.3\lib" -lpq I don't if

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Joey Morris
Aurimas Černius wrote on Wed, Feb 18, 2009 at 06:08:07PM +0200: > Libraries should be places after the source file, that is (not sure > about -L, but for -l surely): > > gcc -o pq_test -I"C:\Program Files\PostgreSQL\8.3\include" pq_test.c > -L"C:\Program Files\PostgreSQL\8.3\lib" -lpq > > I d

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Aurimas Černius
Hi, Looks like you accidently wrote to me personnally, not to mailing list. On Wed, Feb 18, 2009 at 10:01 AM, Aurimas Černius wrote: Did you use *exactly* the same command line to compile both versions? What is that command line(s)? Yes, I used the same compilation command line for both ver

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Joey Morris
Lennin Caro wrote on Wed, Feb 18, 2009 at 06:53:32AM -0800: > try > fprintf(stdout,"Connection \n"); > printf("Connection \n"); Thanks, but both produce the same behavior as fprintf(stderr, "Connection \n"): It prints when the PQconnectdb and PQfinish lines are commented out but not when they a

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Aurimas Černius
Hi, This is my first attempt at using libpq, and I'm running across a strange problem. Here is my bare-bones program: #include #include "libpq-fe.h" int main(int argc, char **argv) { PGconn *conn; fprintf(stderr, "connecting\n"); conn = PQconnectdb("dbname=postgres"); PQfinish(con

Re: [GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Lennin Caro
> This is my first attempt at using libpq, and I'm running > across a strange > problem. Here is my bare-bones program: > > #include > #include "libpq-fe.h" > > int main(int argc, char **argv) { > PGconn *conn; > fprintf(stderr, "connecting\n"); > conn = PQconnectdb("dbname=postgres"); >

[GENERAL] connecting using libpq breaks printf

2009-02-18 Thread Joey Morris
This is my first attempt at using libpq, and I'm running across a strange problem. Here is my bare-bones program: #include #include "libpq-fe.h" int main(int argc, char **argv) { PGconn *conn; fprintf(stderr, "connecting\n"); conn = PQconnectdb("dbname=postgres"); PQfinish(conn); retur