How to run clang-plugin with database connectivity

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

class PrintFunctionNamesAction : public PluginASTAction {
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”);

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!”);

rec_count = PQntuples(res);

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

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



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/ -plugin print-fns -plugin-arg-print-fns -lpq test.cpp
PrintFunctionNames arg = -lpq
clang++: symbol lookup error: …/…/…/…/Release+Asserts/lib/ undefined symbol: PQconnectdb