install libpq C library

sudo yum install rh-postgresql12-postgresql-devel.x86_64

rpm -qa *postgres*
    rh-postgresql12-postgresql-libs-12.1-2.el7.x86_64
    rh-postgresql12-postgresql-devel-12.1-2.el7.x86_64
    rh-postgresql12-runtime-3.4-1.el7.x86_64

rpm -ql rh-postgresql12-postgresql-devel-12.1-2.el7.x86_64
    /opt/rh/rh-postgresql12/root/usr/include
    /opt/rh/rh-postgresql12/root/usr/lib64/libpq.so

install libpqxx C++ Library

git clone https://github.com/jtv/libpqxx.git
cd libpqxx

cmake -DPostgreSQL_LIBRARY=/opt/rh/rh-postgresql12/root/usr/lib64 -DPostgreSQL_INCLUDE_DIR=/opt/rh/rh-postgresql12/root/usr/include -DPostgreSQL_TYPE_INCLUDE_DIR=/opt/rh/rh-postgresql12/root/usr/include ..

vi libpqxx/test/CMakeLists.txt
# change from 'target_link_libraries(unit_runner PUBLIC pqxx)' to
target_link_libraries(unit_runner PUBLIC pqxx /opt/rh/rh-postgresql12/root/usr/lib64/libpq.so)

vi libpqxx/test/unit/CMakeLists.txt
# change from 'target_link_libraries(unit_runner PUBLIC pqxx)' to
target_link_libraries(unit_runner PUBLIC pqxx /opt/rh/rh-postgresql12/root/usr/lib64/libpq.so)

mkdir -p build; cd build
cmake ..
make
sudo make install

create an employee table

drop table employee;
create table Employee(id int, name varchar(20), salary int) ;
insert into Employee values(100, 'Tom', 10000);
insert into Employee values(101, 'Jerry', 8000);
commit; 
select * from employee;

access data thru c++ code

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

int main(int, char *argv[]) {
    pqxx::connection c("postgresql://pg:pg@192.168.157.77/pgsq");
    pqxx::work txn(c);
    pqxx::row r = txn.exec1("SELECT id FROM Employee WHERE name =" + txn.quote(argv[1]));

    int employee_id = r[0].as<int>();
    std::cout << "Updating employee #" << employee_id << std::endl;

    txn.exec0("UPDATE EMPLOYEE SET salary = salary + 1 WHERE id = " + txn.quote(employee_id));
    txn.commit();
}