2

我正在尝试使用安装 RMySQL 包

bash > R
...
> install.packages('RMySQL', repos='http://cran.us.r-project.org')

并在最后得到以下错误输出:

Installing package into ‘/usr/local/lib/R/3.2/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/RMySQL_0.10.6.tar.gz'
Content type 'application/x-gzip' length 52407 bytes (51 KB)
==================================================
downloaded 51 KB

* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
Found mysql_config cflags and libs!
Using PKG_CFLAGS=-I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64
Using PKG_LIBS=-L/usr/local/mysql/lib  -lmysqlclient
** libs
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c RMySQL-init.c -o RMySQL-init.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c connection.c -o connection.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c db-apply.c -o db-apply.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c driver.c -o driver.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c exception.c -o exception.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c fields.c -o fields.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c result.c -o result.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c utils.c -o utils.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -o RMySQL.so RMySQL-init.o connection.o db-apply.o driver.o exception.o fields.o result.o utils.o -L/usr/local/mysql/lib -lmysqlclient -F/usr/local/Cellar/r/3.2.2_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
installing to /usr/local/lib/R/3.2/site-library/RMySQL/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/usr/local/lib/R/3.2/site-library/RMySQL/libs/RMySQL.so':
  dlopen(/usr/local/lib/R/3.2/site-library/RMySQL/libs/RMySQL.so, 6): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /usr/local/lib/R/3.2/site-library/RMySQL/libs/RMySQL.so
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/3.2/site-library/RMySQL’

The downloaded source packages are in
    ‘/private/var/folders/87/wkgwm0754tn9csz8295qjmmc000bxz/T/RtmpxlEAlo/downloaded_packages’
Warning message:
In install.packages("RMySQL", repos = "http://cran.us.r-project.org") :
  installation of package ‘RMySQL’ had non-zero exit status
>
> install.packages('RMySQL', repos='http://cran.us.r-project.org')
Installing package into ‘/usr/local/lib/R/3.2/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/RMySQL_0.10.6.tar.gz'
Content type 'application/x-gzip' length 52407 bytes (51 KB)
==================================================
downloaded 51 KB

* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
Found mysql_config cflags and libs!
Using PKG_CFLAGS=-I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64
Using PKG_LIBS=-L/usr/local/mysql/lib  -lmysqlclient
** libs
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c RMySQL-init.c -o RMySQL-init.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c connection.c -o connection.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c db-apply.c -o db-apply.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c driver.c -o driver.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c exception.c -o exception.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c fields.c -o fields.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c result.c -o result.o
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/mysql/include   -g -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include    -fPIC  -g -O2  -c utils.c -o utils.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -o RMySQL.so RMySQL-init.o connection.o db-apply.o driver.o exception.o fields.o result.o utils.o -L/usr/local/mysql/lib -lmysqlclient -F/usr/local/Cellar/r/3.2.2_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
installing to /usr/local/lib/R/3.2/site-library/RMySQL/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/usr/local/lib/R/3.2/site-library/RMySQL/libs/RMySQL.so':
  dlopen(/usr/local/lib/R/3.2/site-library/RMySQL/libs/RMySQL.so, 6): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /usr/local/lib/R/3.2/site-library/RMySQL/libs/RMySQL.so
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/3.2/site-library/RMySQL’

The downloaded source packages are in
    ‘/private/var/folders/87/wkgwm0754tn9csz8295qjmmc000bxz/T/RtmpxlEAlo/downloaded_packages’
Warning message:
In install.packages("RMySQL", repos = "http://cran.us.r-project.org") :
  installation of package ‘RMySQL’ had non-zero exit status

任何想法?

4

1 回答 1

2

您需要提供有关安装的更多详细信息。我猜你正在使用 R 的自制版本?强烈建议您改用mac 的官方 R 包,这是 CRAN 构建服务器(和大多数用户)正在使用的。

libmysqlclient也就是说,您的安装似乎有些奇怪。假设这是 brew,请尝试重新安装:

brew remove mysql-connector-c
brew upgrade
brew install mysql-connector-c

验证是否libmysqlclient.18.dylib已安装:

ls /usr/local/opt/mysql-connector-c/lib

或者,您可以尝试链接到 mariadb:

brew remove mysql-connector-c
brew install mariadb

如果这不起作用,则可能是 R 的 brew 版本中的错误。编译器无法记录libmysqlclient.18.dylib. 也许 R 没有将正确的RPATH标志传递给链接器。

于 2015-09-07T21:11:27.407 回答