[Libpqxx-general] what's wrong with my basic program?

Caleb Cushing xenoterracide at gmail.com
Wed Sep 9 09:55:44 UTC 2009


#include <iostream>
#include <pqxx/pqxx>

using namespace std;
using namespace pqxx;

int main()
{
    try {
        connection Conn("user=xenoterracide dbname=xenoterracide");
        cout << "Connected to " << Conn.dbname() << endl;
    }
    catch (const exception &e) {
        cerr << e.what() << endl;
        return 1;
    }
    return 0;
}

it fails to link and I'm not sure why. I'm running archlinux

/tmp/cclde6TU.o: In function `main':
dbtest.cpp:(.text+0x2d): undefined reference to
`pqxx::connection_base::dbname()'
/tmp/cclde6TU.o: In function
`pqxx::connect_direct::connect_direct(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)':
dbtest.cpp:(.text._ZN4pqxx14connect_directC1ERKSs[pqxx::connect_direct::connect_direct(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)]+0x1f):
undefined reference to
`pqxx::connectionpolicy::connectionpolicy(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
dbtest.cpp:(.text._ZN4pqxx14connect_directC1ERKSs[pqxx::connect_direct::connect_direct(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)]+0x2a):
undefined reference to `vtable for pqxx::connect_direct'
/tmp/cclde6TU.o: In function `pqxx::connect_direct::~connect_direct()':
dbtest.cpp:(.text._ZN4pqxx14connect_directD1Ev[pqxx::connect_direct::~connect_direct()]+0x13):
undefined reference to `vtable for pqxx::connect_direct'
dbtest.cpp:(.text._ZN4pqxx14connect_directD1Ev[pqxx::connect_direct::~connect_direct()]+0x1f):
undefined reference to `pqxx::connectionpolicy::~connectionpolicy()'
/tmp/cclde6TU.o: In function
`pqxx::basic_connection<pqxx::connect_direct>::basic_connection(char
const*)':
dbtest.cpp:(.text._ZN4pqxx16basic_connectionINS_14connect_directEEC1EPKc[pqxx::basic_connection<pqxx::connect_direct>::basic_connection(char
const*)]+0x2b): undefined reference to
`pqxx::connection_base::connection_base(pqxx::connectionpolicy&)'
dbtest.cpp:(.text._ZN4pqxx16basic_connectionINS_14connect_directEEC1EPKc[pqxx::basic_connection<pqxx::connect_direct>::basic_connection(char
const*)]+0xd6): undefined reference to `pqxx::connection_base::init()'
/tmp/cclde6TU.o: In function
`pqxx::basic_connection<pqxx::connect_direct>::~basic_connection()':
dbtest.cpp:(.text._ZN4pqxx16basic_connectionINS_14connect_directEED1Ev[pqxx::basic_connection<pqxx::connect_direct>::~basic_connection()]+0x17):
undefined reference to `pqxx::connection_base::close()'
collect2: ld returned 1 exit status

-- 
Caleb Cushing

http://xenoterracide.blogspot.com


More information about the Libpqxx-general mailing list