On Tue, Mar 25, 2008 at 10:17:28PM +0100, Marius Hooge wrote:
> I think this is kind of offtopic, but google couldn't help and I don't 
> know where else I could ask.
> 
> I'd like to write a postgresql client in c++ with libpqxx from the ports 
> and can't get it to link.
> (If I recall correctly, the libpqxx port is only used by koffice.)
> I'm a little bit unexperienced with linking to other libraries, so it
> could be something very obvious and a goto to a manual sufficiently helpful.
> I'm running an approx. one week old snapshot on i386.
> 
> main.cpp:
> #include <pqxx/pqxx>
> int main(){
>  pqxx::connection Conn("dbname=test");
>  return 0;
> }
> 
> and I tried to compile it with:
> $ c++ -Wall -I /usr/local/include -L /usr/local/lib -o dbconntest main.cpp

I think you want

$ c++ `pkg-config --cflags libpqxx` `pkg-config --libs libpqxx` -o dbconntest 
main.cpp

or maybe

$ c++ `pqxx-config --cflags` `pqxx-config --libs` -o dbconntest main.cpp

not tested though

> and get this result:
> /tmp//ccG13636.o(.text+0x2b): In function `main':
> : undefined reference to `pqxx::connection::connection[in-charge](char 
> const*)'
> /tmp//ccG13636.o(.text+0x3d): In function `main':
> : undefined reference to `pqxx::connection::~connection [in-charge]()'
> collect2: ld returned 1 exit status
> *** Error code 1
> 
> I also tried to link directly via -l with no success.
> 
> Any help would be appreciated - thank you.
> 

-- 
[EMAIL PROTECTED]
SDF Public Access UNIX System - http://sdf.lonestar.org

Reply via email to