Skip to content

libpq-fe.h not found even though libpq-dev installed on Debian #350

Closed

Description

@gontcharovd

Hello, I'm trying to install RPostgres in the a Docker container. However, the compilation fails because the libpq-fe.h file can't be found even though it exists:

# locate libpq-fe.h
/usr/include/postgresql/libpq-fe.h

This is the error message:

> install.packages("RPostgres")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/RPostgres_1.4.1.tar.gz'
Content type 'application/x-gzip' length 1551420 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

* installing *source* package ‘RPostgres’ ...
** package ‘RPostgres’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs (libpq 14.0)!
Using PKG_CFLAGS=
Using PKG_LIBS=-lpq
Using PKG_PLOGR=
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -Ivendor -DRCPP_DEFAULT_INCLUDE_CALL=false -DRCPP_USING_UTF8_ERROR_STRING -DBOOST_NO_AUTO_PTR  -I'/usr/local/lib/R/site-library/plogr/include' -I'/usr/local/lib/R/site-library/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-4.1.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c DbColumn.cpp -o DbColumn.o
In file included from DbColumn.cpp:1:
pch.h:2:10: fatal error: libpq-fe.h: No such file or directory
    2 | #include <libpq-fe.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:177: DbColumn.o] Error 1
ERROR: compilation failed for package ‘RPostgres’
* removing ‘/usr/local/lib/R/site-library/RPostgres’

The downloaded source packages are in
        ‘/tmp/RtmpvKl0f8/downloaded_packages’
Warning message:
In install.packages("RPostgres") :
  installation of package ‘RPostgres’ had non-zero exit status

This is the Docker image I'm building:

FROM rocker/r-base:4.1.1

RUN apt update 
RUN apt install -y libcurl4-openssl-dev libmagick++-dev libpq-dev unixodbc-dev

ENTRYPOINT ["tail", "-f", "/dev/null"]

I set the following environment variables inside the container:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/include/postgresql
export C_INCLUDE_PATH=$(pg_config --includedir):${C_INCLUDE_PATH}
export LD_LIBRARY_PATH=$(pg_config --libdir):${LD_LIBRARY_PATH}

I can install RPostgreSQL without any problems so I don't think it's an issue with libpq-dev.

This is the output from pg_config:

pg_config

BINDIR = /usr/lib/postgresql/14/bin
DOCDIR = /usr/share/doc/postgresql-doc-14
HTMLDIR = /usr/share/doc/postgresql-doc-14
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/14/server
LIBDIR = /usr/lib/x86_64-linux-gnu
PKGLIBDIR = /usr/lib/postgresql/14/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/14/man
SHAREDIR = /usr/share/postgresql/14
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/14/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' 'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/14/man' '--docdir=/usr/share/doc/postgresql-doc-14' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/14' '--bindir=/usr/lib/postgresql/14/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Debian 14.0-1)' '--enable-nls' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' '--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-lz4' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' 'LLVM_CONFIG=/usr/bin/llvm-config-11' 'CLANG=/usr/bin/clang-11' '--with-systemd' '--with-selinux' 'AWK=mawk' 'MKDIR_P=/bin/mkdir -p' 'PROVE=/usr/bin/prove' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' 'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
CC = gcc
CPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-11/lib -Wl,--as-needed
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lselinux -llz4 -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lpthread -lrt -ldl -lm
VERSION = PostgreSQL 14.0 (Debian 14.0-1)

Activity

  1. krlmlr commented on Oct 17, 2021

    @krlmlr
    Member

    Thanks. Something weird is going on with pkg-config:

    Using PKG_CFLAGS=
    Using PKG_LIBS=-lpq
    Using PKG_PLOGR=
    

    What does pkg-config --cflags libpq return in your container?

  2. added
    install
    on Oct 17, 2021
  3. gontcharovd commented on Oct 21, 2021

    @gontcharovd
    Author

    Hey, this is what pkg-config --cflags libpq returns:

    Package libssl was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libssl.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libssl', required by 'libpq', not found
    
  4. krlmlr commented on Oct 29, 2021

    @krlmlr
    Member

    Looks like you need to provide libssl to fix pkgconfig --cflags ?

  5. krlmlr commented on Nov 7, 2021

    @krlmlr
    Member

    Confirming that installing libssl-dev fixes the problem. I'll tweak the configure script to include this information.

  6. added this to the 1.4.1 milestone on Nov 7, 2021
  7. modified the milestones: 1.4.1, 1.4.2 on Dec 5, 2021
  8. github-actions commented on Dec 7, 2022

    @github-actions
    Contributor

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

  9. locked and limited conversation to collaborators on Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    install

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions