How to compile the following linux program with postgres libraries
#include <iostream> //using namespace std; #include <stdio.h> #include <postgresql/libpq-fe.h> #include <string> #include <cstdio> #include <stdlib.h> #include <libc.h> int main() { PGconn *conn; PGresult *res; int rec_count; int row; int col; FILE *stream; conn = PQconnectdb("hostaddr=192.168.143.92 port=5432 connect_timeout=5 dbname=NexentaSearch user=DKOI password=21111991"); if (PQstatus(conn) == CONNECTION_BAD) { puts("Не удается подключиться к базе данных"); exit(0); } res = PQexec(conn, "select path from paths order by id"); if (PQresultStatus(res) != PGRES_TUPLES_OK) { printf("Мы не получили данные"); exit(0); } rec_count = PQntuples(res); printf("Мы получили %d записей.\n", rec_count); puts("=========================="); stream=fopen("usr/local/ paths.txt ", "w"); for (row=0; row<rec_count; row++) { for (col=0; col<1; col++) { fprintf(stream, "%s\n", PQgetvalue(res, row, col)); } puts(""); } puts("=========================="); PQclear(res); PQfinish(conn); return 0; }
Attempting to compile with gcc -c readwritepaths.cpp
resulted in an error
gcc: error trying to exec 'cc1plus': execvp: No such file or directory