libpqxx: File missing in installation

I’m on Ubuntu 22.04 trying to properly link and compile a sample c++ program that will let me use libpqxx to connect to a postgres database.

Something is wrong in my setup – likely something to do with the way I’m linking the files, or perhaps with any errors I’ve made in the installation process.

Here is my sample program:

#include <iostream>
#include <fstream>
#include <iomanip>
// #include "postgresql/libpq-fe.h"
#include <pqxx/pqxx>

using std::cout;
using std::endl;

int main ()

{

    pqxx::connection conn("dbname=postgres user=postgres password=asdf \
            hostaddr=127.0.0.1  port=5432");

    cout << "Test" << endl;

    return 0;

}

Here is my Makefile

TARGET = prog
SOURCES = $(wildcard *.cpp)
HEADERS = $(wildcard *.h*)
OBJECTS = $(SOURCES:%.cpp=%.o)
LD = g++ 
CXX = g++ 
CXXFLAGS = -std=c++17 -g -Wall -Iinclude -lpqxx -lpq -DGL_SILENCE_DEPRECATION
LDFLAGS = 

.PHONY: all clean

all: $(TARGET)

clean:
    $(RM) src/*.o
    $(RM) $(TARGET)

$(TARGET): $(OBJECTS)
    $(LD) -o $@ $(OBJECTS) $(LDFLAGS)

%.o: %.cpp $(HEADERS)
    $(CXX) $(CXXFLAGS) -c $< -o $@

When I enter make at the terminal in the directory of main.cpp, here is the error output:

$ make
g++ -std=c++17 -g -Wall -Iinclude -lpqxx -lpq -DGL_SILENCE_DEPRECATION -c main.cpp -o main.o
In file included from /usr/local/include/pqxx/transaction_base.hxx:35,
                 from /usr/local/include/pqxx/dbtransaction.hxx:20,
                 from /usr/local/include/pqxx/blob.hxx:34,
                 from /usr/local/include/pqxx/pqxx:6,
                 from main.cpp:5:
/usr/local/include/pqxx/internal/stream_query.hxx:29:10: fatal error: pqxx/internal/gates/connection-stream_from.hxx: No such file or directory
   29 | #include "pqxx/internal/gates/connection-stream_from.hxx"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:22: main.o] Error 1

When I go to the indicated directory, I can see that indeed this file is missing:

$ cd /usr/local/include/pqxx/internal/gates
$ ls
connection-errorhandler.hxx           connection-transaction.hxx          result-creation.hxx
connection-largeobject.hxx            errorhandler-connection.hxx         result-pipeline.hxx
connection-notification_receiver.hxx  icursor_iterator-icursorstream.hxx  result-sql_cursor.hxx
connection-pipeline.hxx               icursorstream-icursor_iterator.hxx  transaction-sql_cursor.hxx
connection-sql_cursor.hxx             result-connection.hxx               transaction-transaction_focus.hxx

It’s not clear to me why this file would be missing?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Already on it. It was my mistake — it seems I neglected to add some internal header files to a listing in one of the Makefile.am files. The CMake build should work, but I’m also about to merge some fixes: #658 (for master), #659 (for the 7.7 release series), and possibly more.