Received: from smtp.cistron-office.nl (10fwd.cistron-office.nl [195.64.65.197]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f2UCOxK30888 for ; Fri, 30 Mar 2001 07:24:59 -0500 (EST) (envelope-from jtv@cistron-office.nl) Received: from slipstream.cistron-office.nl ([195.64.65.252]) by smtp.cistron-office.nl with smtp (Exim 3.22 #1 (Debian)) id 14ixxN-0005XK-00; Fri, 30 Mar 2001 14:24:45 +0200 Received: by slipstream.cistron-office.nl (sSMTP sendmail emulation); Fri, 30 Mar 2001 14:24:45 +0200 From: "J. T. Vermeulen" Date: Fri, 30 Mar 2001 14:24:45 +0200 To: Shane Hansen Cc: pgsql-interfaces@postgresql.org Subject: Re: c++ compile/link problem Message-ID: <20010330142445.G5047@cistron.nl> Mail-Followup-To: Shane Hansen , pgsql-interfaces@postgresql.org References: <003601c0b8e3$b2693460$61e97b81@usu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <003601c0b8e3$b2693460$61e97b81@usu.edu>; from sl1fm@cc.usu.edu on Thu, Mar 29, 2001 at 11:36:05PM -0700 X-Disclaimer: Include standard disclaimer here. X-Archive-Number: 200103/211 X-Sequence-Number: 1373 On Thu, 29 Mar 2001, Shane Hansen wrote: > I am struggling trying to get a connection to my postgres database from a c++ program. I have read the documention and looked at many examples, but when I try to compile the code I get the same type errors every time. They look like: > > /tmp/cc38u8Jz.o: In function `main': > /tmp/cc38u8Jz.o(.text+0x3b): undefined reference to `PgConnection::PgConnection( > char const *)' > /tmp/cc38u8Jz.o(.text+0x4e): undefined reference to `PgConnection::~PgConnection > (void)' > collect2: ld returned 1 exit status > > What am I doing wrong? I'm assuming you've remembered to link to libpq++ here. This may be a problem with your C++ compiler. Different compilers, and in some cases even different versions of the same compiler, mangle C++ identifiers differently so they won't link to each other's code (and before you ask: yes, there are good reasons for this--see the C++ FAQ :-). Have you made sure your version of libpq++ was build with the same compiler? Jeroen