对于 R,安装 RMySQL 包时出错
For R, error in installing RMySQL package
我正在尝试使用
安装 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
有什么想法吗?
您需要提供有关安装的更多详细信息。我猜你正在使用 R 的自制版本?强烈建议您改用官方 R package for mac,这是 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 标志传递给链接器。
我正在尝试使用
安装 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
有什么想法吗?
您需要提供有关安装的更多详细信息。我猜你正在使用 R 的自制版本?强烈建议您改用官方 R package for mac,这是 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 标志传递给链接器。