Search code examples
c++postgresqllibpqxx

pqxx simple code crashed


The following code crashed

int main()
{
    std::string connstring = "host=* port=* user=* password=* dbname=*";
    pqxx::connection connection(connstring);

    if (connection.is_open()) {
        pqxx::work transaction(connection);
        transaction.exec("SELECT 1;");
        transaction.commit();
    }

    return 0;
}

With message:

double free or corruption

What am I doing wrong?


Solution

  • I will answer myself. The following solution helped:

    sudo apt-get remove libpq5
    sudo apt-get install libpq-dev