How to run clang-plugin with database connectivity

I have written postgerSql connectivity code in clang plugin as shown below.

class PrintFunctionNamesAction : public PluginASTAction {
protected:
ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef) {
PGconn *conn;
PGresult *res;
int rec_count;
int row;
int col;

conn = PQconnectdb(“dbname=a host=localhost user=user password=user123”);

if (PQstatus(conn) == CONNECTION_BAD) {
puts(“We were unable to connect to the database”);
//break;
}

res = PQexec(conn,
“update people set phonenumber=‘8983194618’ where id=3”);

res = PQexec(conn,
“select lastname,firstname,phonenumber from people order by id”);

if (PQresultStatus(res) != PGRES_TUPLES_OK) {
puts(“We did not get any data!”);
//break;
}

rec_count = PQntuples(res);

printf(“We received %d records.\n”, rec_count);
puts("==========================");

for (row=0; row<rec_count; row++) {
for (col=0; col<3; col++) {
printf("%s\t", PQgetvalue(res, row, col));
}
puts("");
}

puts("==========================");

PQclear(res);

PQfinish(conn);
return new PrintFunctionsConsumer();
}

It does not give any compile time error; but I am getting the following error ar run time.

clang++ -cc1 -load …/…/…/…/Release+Asserts/lib/libPrintFunctionNames.so -plugin print-fns -plugin-arg-print-fns -lpq test.cpp
PrintFunctionNames arg = -lpq
clang++: symbol lookup error: …/…/…/…/Release+Asserts/lib/libPrintFunctionNames.so: undefined symbol: PQconnectdb