安装 RMysql RHEL 7.3 出错

Error install RMysql RHEL 7.3

我正在使用: R 版本:3.3.3.
OS:EC2 上的 RHEL 7.3。
我正在尝试安装 RMysql。
所以在 R 终端我提交命令:install.packages("RMySQL")

第一次尝试不成功,并给出错误 libmysql找不到客户端

Using PKG_LIBS=-lmysqlclient
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libmysqlclient was not found. Try installing:
 * deb: libmariadb-client-lgpl-dev (Debian, Ubuntu 16.04)
        libmariadbclient-dev (Ubuntu 14.04)
 * rpm: mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
 * csw: mysql56_dev (Solaris)
 * brew: mariadb-connector-c (OSX)
If libmysqlclient is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libmysqlclient.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/usr/lib64/R/library/RMySQL’

The downloaded source packages are in
    ‘/tmp/Rtmpx1vsUG/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("RMySQL") :
  installation of package ‘RMySQL’ had non-zero exit status

所以我安装了mysql-devel。 (sudo yum install mysql-devel)

在此之后,我再次尝试安装 RMysql。 但这不再起作用。 PKG_LIBS -lmariadb.

有问题

gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o RMySQL.so RMySQL-init.o connection.o db-apply.o driver.o exception.o fields.o result.o utils.o -L/usr/lib64/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto -L/usr/lib64/R/lib -lR /bin/ld: 找不到 -lmariadb

这是整个 R 输出。

* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
Found mysql_config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/mysql -I/usr/include/mysql/mysql
Using PKG_LIBS=-L/usr/lib64/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RMySQL-init.c -o RMySQL-init.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c connection.c -o connection.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c db-apply.c -o db-apply.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c driver.c -o driver.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c exception.c -o exception.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c fields.c -o fields.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c result.c -o result.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c utils.c -o utils.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o RMySQL.so RMySQL-init.o connection.o db-apply.o driver.o exception.o fields.o result.o utils.o -L/usr/lib64/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto -L/usr/lib64/R/lib -lR
/bin/ld: cannot find -lmariadb
collect2: error: ld returned 1 exit status
make: *** [RMySQL.so] Error 1
ERROR: compilation failed for package ‘RMySQL’
* removing ‘/usr/lib64/R/library/RMySQL’

The downloaded source packages are in
    ‘/tmp/RtmpYEs7XA/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("RMySQL") :
  installation of package ‘RMySQL’ had non-zero exit status

好的,我终于知道如何解决这个问题了!!! 为自己感到骄傲:)

我安装了 mariadb-devel

Name : MariaDB-devel
Arch : x86_64
Version : 10.2.6
Release : 1.el7.centos

libmariadb.so 丢失。 相反,我有 libmariadbclient.a。 (/usr/lib64/libmariadbclient.a)
所以我不得不做一个象征性的 link:

sudo ln -s /usr/lib64/libmariadbclient.a /usr/lib64/libmariadb.a

安装 RMysql 成功后:

** building package indices
** testing if installed package can be loaded
* DONE (RMySQL)
Making 'packages.html' ... done