Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gontcharovd opened this issue Oct 14, 2021 · 5 comments
Closed

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

gontcharovd opened this issue Oct 14, 2021 · 5 comments
Labels
install Issues with custom installations
Milestone

Comments

@gontcharovd
Copy link


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’
(aslibis 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* packageRPostgres...
** packageRPostgressuccessfully 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 packageRPostgres* removing/usr/local/lib/R/site-library/RPostgresThe downloaded source packages are in/tmp/RtmpvKl0f8/downloaded_packagesWarning message:
In install.packages("RPostgres") :
  installation of packageRPostgreshad 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)

@krlmlr
Copy link
Member

krlmlr commented Oct 17, 2021

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?

@krlmlr krlmlr added the install Issues with custom installations label Oct 17, 2021
@gontcharovd
Copy link
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

@krlmlr
Copy link
Member

krlmlr commented Oct 29, 2021

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

@krlmlr
Copy link
Member

krlmlr commented Nov 7, 2021

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

@krlmlr krlmlr closed this as completed in 5533405 Nov 7, 2021
@krlmlr krlmlr added this to the 1.4.1 milestone Nov 7, 2021
@krlmlr krlmlr modified the milestones: 1.4.1, 1.4.2 Dec 5, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2022

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.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install Issues with custom installations
Projects
None yet
Development

No branches or pull requests

2 participants