fatal error: 'libpq-fe.h' file not found
と、エラーになってインストールできなかった。
> install.packages("RPostgreSQL")
ソースコードの形でのみ利用可能なパッケージです,C/C++/Fortran でコンパイルの必要があるかもしれません : ‘RPostgreSQL’
ソースファイルからのインストールを試みますか?
y/n: y
ソースパッケージ ‘RPostgreSQL’ をインストール中です
URL 'https://cran.ism.ac.jp/src/contrib/RPostgreSQL_0.4-1.tar.gz' を試しています
Content type 'application/x-gzip' length 476204 bytes (465 KB)
==================================================
downloaded 465 KB
* installing *source* package ‘RPostgreSQL’ ...
** パッケージ ‘RPostgreSQL’ の解凍および MD5 サムの検証に成功しました
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 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-apple-darwin16.6.0
checking host system type... x86_64-apple-darwin16.6.0
checking target system type... x86_64-apple-darwin16.6.0
checking for pg_config... no
configure: checking for PostgreSQL header files
configure: Checking include /usr/include.
configure: Checking include /usr/include/pgsql.
configure: Checking include /usr/include/postgresql.
configure: Checking include /usr/local/include.
configure: Checking include /usr/local/include/pgsql.
configure: Checking include /usr/local/include/postgresql.
configure: Checking include /usr/local/pgsql/include.
configure: Checking include /usr/local/postgresql/include.
configure: Checking include /opt/include.
configure: Checking include /opt/include/pgsql.
configure: Checking include /opt/include/postgresql.
configure: Checking include /opt/local/include.
configure: Checking include /opt/local/include/postgresql.
configure: Checking include /opt/local/include/postgresql84.
configure: Checking include /sw/opt/postgresql-8.4/include.
configure: Checking include /Library/PostgresPlus/8.4SS/include.
configure: Checking include /sw/include/postgresql.
configure: Checking lib /usr/lib.
checking for "/libpq-fe.h"... no
configure: creating ./config.status
config.status: creating src/Makevars
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I -I/usr/local/include -fPIC -Wall -g -O2 -c RS-DBI.c -o RS-DBI.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I -I/usr/local/include -fPIC -Wall -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' file not found
# include "libpq-fe.h"
^
1 error generated.
make: *** [RS-PQescape.o] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RPostgreSQL’
ダウンロードされたパッケージは、以下にあります
‘/private/var/folders/gd/bsnn_w893mx793c0kyls0_080000gn/T/RtmpZ92wvv/downloaded_packages’
警告メッセージ:
install.packages("RPostgreSQL") で:
パッケージ ‘RPostgreSQL’ のインストールは、ゼロでない終了値をもちました
しかたがないので、
brew install postgres
した。postgresql-devel とかは見つからなかった。
$ brew install postgresql
Updating Homebrew...
==> Installing dependencies for postgresql: openssl
==> Installing postgresql dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2l.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2l.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
==> Summary
/usr/local/Cellar/openssl/1.0.2l: 1,709 files, 12.2MB
==> Installing postgresql
==> Downloading https://homebrew.bintray.com/bottles/postgresql-9.6.3.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring postgresql-9.6.3.sierra.bottle.tar.gz
==> /usr/local/Cellar/postgresql/9.6.3/bin/initdb /usr/local/var/postgres
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/legacy-homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.0) of PostgreSQL, see:
https://www.postgresql.org/docs/9.6/static/upgrading.html
To migrate existing data from a previous minor version (9.0-9.5) of PostgreSQL, see:
https://www.postgresql.org/docs/9.6/static/pgupgrade.html
You will need your previous PostgreSQL installation from brew to perform `pg_upgrade`.
Do not run `brew cleanup postgresql` until you have performed the migration.
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Summary
/usr/local/Cellar/postgresql/9.6.3: 3,259 files, 36.6MB
再度インストールを試み、今度は成功。
> install.packages("RPostgreSQL")
ソースコードの形でのみ利用可能なパッケージです,C/C++/Fortran でコンパイルの必要があるかもしれません : ‘RPostgreSQL’
ソースファイルからのインストールを試みますか?
y/n: y
ソースパッケージ ‘RPostgreSQL’ をインストール中です
URL 'https://cran.ism.ac.jp/src/contrib/RPostgreSQL_0.4-1.tar.gz' を試しています
Content type 'application/x-gzip' length 476204 bytes (465 KB)
==================================================
downloaded 465 KB
* installing *source* package ‘RPostgreSQL’ ...
** パッケージ ‘RPostgreSQL’ の解凍および MD5 サムの検証に成功しました
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 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-apple-darwin16.6.0
checking host system type... x86_64-apple-darwin16.6.0
checking target system type... x86_64-apple-darwin16.6.0
checking for pg_config... /usr/local/bin/pg_config
checking for "/usr/local/Cellar/postgresql/9.6.3/include/libpq-fe.h"... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-DBI.c -o RS-DBI.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-PQescape.c -o RS-PQescape.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-PostgreSQL.c -o RS-PostgreSQL.o
RS-PostgreSQL.c:446:13: warning: incompatible pointer types passing 'RS_DBI_fields *' (aka 'struct st_sdbi_fields *') to parameter of type 'SEXP' (aka 'struct SEXPREC *') [-Wincompatible-pointer-types]
PROTECT(flds = RS_DBI_allocFields(num_fields));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/R.framework/Resources/include/Rinternals.h:691:31: note: expanded from macro 'PROTECT'
#define PROTECT(s) Rf_protect(s)
^
/Library/Frameworks/R.framework/Resources/include/Rinternals.h:1419:21: note: passing argument to parameter here
SEXP Rf_protect(SEXP);
^
1 warning generated.
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-pgsql-copy.c -o RS-pgsql-copy.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-pgsql-getResult.c -o RS-pgsql-getResult.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-pgsql-pqexec.c -o RS-pgsql-pqexec.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/postgresql/9.6.3/include -I/usr/local/include -fPIC -Wall -g -O2 -c RS-pgsql-pqexecparams.c -o RS-pgsql-pqexecparams.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o RPostgreSQL.so RS-DBI.o RS-PQescape.o RS-PostgreSQL.o RS-pgsql-copy.o RS-pgsql-getResult.o RS-pgsql-pqexec.o RS-pgsql-pqexecparams.o -L/usr/local/lib -lpq -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RPostgreSQL/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (RPostgreSQL)
ダウンロードされたパッケージは、以下にあります
‘/private/var/folders/gd/bsnn_w893mx793c0kyls0_080000gn/T/RtmpZ92wvv/downloaded_packages’