在Ubuntu 20.04.4 LTS中编译,g++返回
libpq-fe.h is not found
系统已经安装了libpq-dev (sudo apt-get install libpq-dev)在
/usr/include/postgresql/libpq-fe.h
我尝试用选项-I/usr/include/postgresql设置编译路径,但它仍然声称缺少libpq-fe.h
您可以看到,我必须手动插入-I/usr/include/postgresql和- l/usr/lib/x86_64-linux-gnu让-lpq (libpq)在Ubuntu中与g++一起工作:
TARGET = prog
LIBS = -lm -lcrypto -lpq -lpthread
CC = g++
CFLAGS = -g -Wall
ODIR = ../src
.PHONY: default all clean
default: $(TARGET)
all: default
OBJS = $(patsubst %.cpp, %.o, $(wildcard ../src/*.cpp))
HEADERS = $(wildcard ../src/*.h)
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) -L/usr/lib/x86_64-linux-gnu -o $@ $^ $(LIBS)
$(ODIR)/%.o: $(ODIR)/%.cpp
$(CC) $(CFLAGS) -I/usr/include/postgresql -c $< -o $@
clean:
-rm -f ../src/*.o
-rm -f $(TARGET)
如果">不能找到-lpq";libpq.so。/usr/lib/x86_64-linux-gnu:
sudo ln -s /usr/lib/x86_64-linux-gnu/libpq.so.5 /usr/lib/x86_64-linux-gnu/libpq.so