tomoakin / RPostgreSQL

Automatically exported from code.google.com/p/rpostgresql
64 stars 20 forks source link

Issue installing RPostgreSQL on linux #116

Closed Hamedhm closed 2 years ago

Hamedhm commented 2 years ago

Thanks for the great work.

I am trying to install RPostgreSQL on a local Linux environment. When I hit the install.packages('RPostgreSQL') I get:

* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for pg_config... no
configure: checking for PostgreSQL header files
configure: Checking include /usr/include.
configure: Checking include /usr/include/postgresql.
configure: Checking include /usr/local/include.
configure: Checking include /usr/local/include/postgresql.
configure: Checking include /usr/local/pgsql/include.
configure: Checking include /usr/local/postgresql/include.
configure: Checking lib /usr/lib.
configure: Checking lib /usr/lib/postgresql.
configure: Checking lib /usr/local/lib.
configure: Checking lib /usr/local/lib/postgresql.
configure: Checking lib /usr/local/postgresql/lib.
configure: Using internal package libpq-fe.h
checking for "src/libpq/libpq-fe.h"... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/hps/software/spack/opt/spack/linux-centos8-sandybridge/gcc-9.3.0/gcc-9.3.0-lnsweiq6ddiz4zh3jwrepvcwhtp6oj2q/bin/gcc -I"/hps/software/spack/opt/spack/linux-centos8-sandybridge/gcc-9.3.0/r-4.0.3-xiarbub5lzxgxxmtzsewqc23velt7pl7/rlib/R/include" -DNDEBUG -Isrc/libpq  -I/usr/local/include   -fpic  -g -O2  -c RS-DBI.c -o RS-DBI.o
/hps/software/spack/opt/spack/linux-centos8-sandybridge/gcc-9.3.0/gcc-9.3.0-lnsweiq6ddiz4zh3jwrepvcwhtp6oj2q/bin/gcc -I"/hps/software/spack/opt/spack/linux-centos8-sandybridge/gcc-9.3.0/r-4.0.3-xiarbub5lzxgxxmtzsewqc23velt7pl7/rlib/R/include" -DNDEBUG -Isrc/libpq  -I/usr/local/include   -fpic  -g -O2  -c RS-PQescape.c -o RS-PQescape.o
In file included from RS-PQescape.c:7:
RS-PostgreSQL.h:23:14: fatal error: libpq-fe.h: No such file or directory
   23 | #    include "libpq-fe.h"
      |              ^~~~~~~~~~~~
compilation terminated.

The error is related to libpq-fe.h that I talked to out IT team and they said it is in

-rw-r--r-- 1 root root 22K Feb 11 2021 /usr/pgsql-11/include/libpq-fe.h

Is there any way that we get around this issue?

Hamedhm commented 2 years ago

Hi, can someone please contribute to this?

benz0li commented 2 years ago

@Hamedhm Maybe https://stackoverflow.com/questions/56230187/no-such-file-error-libpq-fe-h-when-installing-postgresql-package-for-r-on-linux?

The install script is looking for PostgreSQLheader files in the following directories:

[...]
configure: Checking include /usr/include.
configure: Checking include /usr/include/postgresql.
configure: Checking include /usr/local/include.
configure: Checking include /usr/local/include/postgresql.
configure: Checking include /usr/local/pgsql/include.
configure: Checking include /usr/local/postgresql/include.
[...]

IMHO /usr/pgsql-11/include/ does not look like a standard location.

Hamedhm commented 2 years ago

Thanks @benz0li

Is there any way that I pass the path as a parameter to the installation process?

benz0li commented 2 years ago

Try

install.packages("RPostgreSQL", configure.args = c(PG_INCDIR = "/usr/pgsql-11/include")

You may also set PG_LIBDIR.

tomoakin commented 2 years ago

Do you have the program named pg_config in a place specified in the PATH environmental variable? In normal installation in various unix systems, postgresql installation should have pg_config and pg_config tells includes and library files.

If the IT person says the includes are in /usr/pgsql-11/include/libpq-fe.h some likely place is /usr/pgsql-11/bin If not, you can ask where pg_config, psql etc. are placed.

Hamedhm commented 2 years ago

Oh thank you very much.

I added /usr/pgsql-11/bin to .bash_profile and it works now. Thanks for the lovely help