我在安装RMySQL时遇到麻烦。我试图通过以下方式从它的源代码安装它:
install.packages("/path/to/package/RMySQL_0.9-3.tar.gz",repos = NULL,type="source")然后我得到:
Installing package into ‘/Users/Library/R/3.1/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
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 ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for compress in -lz... yes
checking for getopt_long in -lc... yes
checking for mysql_init in -lmysqlclient... no
checking for egrep... grep -E
checking for ANSI C header files...
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking /usr/local/include/mysql/mysql.h usability... no
checking /usr/local/include/mysql/mysql.h presence... no
checking for /usr/local/include/mysql/mysql.h... no
checking /usr/include/mysql/mysql.h usability... no
checking /usr/include/mysql/mysql.h presence... no
checking for /usr/include/mysql/mysql.h... no
checking /usr/local/mysql/include/mysql/mysql.h usability... no
checking /usr/local/mysql/include/mysql/mysql.h presence... no
checking for /usr/local/mysql/include/mysql/mysql.h... no
checking /opt/include/mysql/mysql.h usability... no
checking /opt/include/mysql/mysql.h presence... no
checking for /opt/include/mysql/mysql.h... no
checking /include/mysql/mysql.h usability... no
checking /include/mysql/mysql.h presence... no
checking for /include/mysql/mysql.h... no
Configuration error:
could not find the MySQL installation include and/or library
directories. Manually specify the location of the MySQL
libraries and the header files and re-run R CMD INSTALL.
INSTRUCTIONS:
1. Define and export the 2 shell variables PKG_CPPFLAGS and
PKG_LIBS to include the directory for header files (*.h)
and libraries, for example (using Bourne shell syntax):
export PKG_CPPFLAGS="-I<MySQL-include-dir>"
export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"
Re-run the R INSTALL command:
R CMD INSTALL RMySQL_<version>.tar.gz
2. Alternatively, you may pass the configure arguments
--with-mysql-dir=<base-dir> (distribution directory)
or
--with-mysql-inc=<base-inc> (where MySQL header files reside)
--with-mysql-lib=<base-lib> (where MySQL libraries reside)
in the call to R INSTALL --configure-args='...'
R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/Library/R/3.1/library/RMySQL’
Warning in install.packages :
installation of package ‘/path/to/package/RMySQL_0.9-3.tar.gz’ had non-zero exit status我可能会因为这件事而大喊大叫,因为我得到了指示,但语言在我的头上,我已经尝试了两个小时。有人能帮忙吗?
发布于 2014-07-13 04:39:42
我已经成功地从RMySQL源代码安装了Mac0.9-3:
要实现同样的目标,有其他选择,但我会尽力提供最友好的方式。以下是主要步骤:
1.确保您有"gcc“可用。(看起来您有)
转到应用程序>实用程序,打开终端,并键入以下命令来验证命令行工具的存在:($是终端中的命令提示符)
$ gcc
clang: error: no input files如果收到-bash: gcc: command not found,则需要以独立的或Xcode方式安装命令行工具(gcc)。
2.通过国产.安装MySQL客户端
自制软件是一个包管理系统,它简化了Mac操作系统上软件的安装。
首先,从终端安装国产啤酒:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"然后,键入"brew“命令,以检查是否安装了Homebrew。然后通过Homebrew安装MySQL:
$ brew install mysql您应该会看到下载、倾注、警告以及最后显示安装了MySQL的摘要。
您可以使用(默认)空密码以根用户身份连接到本地MySQL服务器来验证安装:
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.19 Homebrew
... (skipped) ...
mysql> 使用" exit“退出MySQL外壳。您可能在启动或连接本地MySQL服务器时遇到问题,但这超出了范围。
3.从RStudio.中的源代码安装RMySQL
到目前为止,所有步骤都是在终点站完成的。虽然这个步骤也可以在终端中完成,但我将展示如何在RStudio中完成它。从您的错误消息:
Configuration error:
could not find the MySQL installation include and/or library
directories. Manually specify the location of the MySQL
libraries and the header files and re-run R CMD INSTALL.
INSTRUCTIONS:
1. Define and export the 2 shell variables PKG_CPPFLAGS and
PKG_LIBS to include the directory for header files (*.h)
and libraries, for example (using Bourne shell syntax):
export PKG_CPPFLAGS="-I<MySQL-include-dir>"
export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"
Re-run the R INSTALL command:
R CMD INSTALL RMySQL_<version>.tar.gz这意味着R无法找到要包含的头文件(包括内容)和链接到的库(lib things)。
该指令告诉您设置2个环境变量PKG_CPPFLAGS和PKG_LIBS,以指示包含和lib在哪里。
假设您已经安装了带有默认路径的MySQL。在RStudio中,您可以通过以下方式设置它们:(>是RStudio中的命令提示符)
### These are the KEY COMMANDS in this turotial ###
> Sys.setenv(PKG_CPPFLAGS = "-I/usr/local/include/mysql")
> Sys.setenv(PKG_LIBS = "-L/usr/local/lib -lmysqlclient")最后,您应该能够正确地从源代码安装RMySQL!无论是从CRAN还是本地文件。
> install.packages("RMySQL", type = "source")或
> install.packages("/path/to/package/RMySQL_0.9-3.tar.gz", repos = NULL, type = "source")两者都会给你成功的信息:
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include/mysql/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c RS-DBI.c -o RS-DBI.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include/mysql/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c RS-MySQL.c -o RS-MySQL.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o RMySQL.so RS-DBI.o RS-MySQL.o -L/usr/local/lib/ -lmysqlclient -lz -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs
** R
** inst
** preparing package for lazy loading
Creating a generic function for ‘format’ from package ‘base’ in package ‘RMySQL’
Creating a generic function for ‘print’ from package ‘base’ in package ‘RMySQL’
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (RMySQL)与往常一样,通过以下方式加载RMySQL包:
> library(RMySQL)
Loading required package: DBI
> 注意:R中的install.packages()实际上在终端(Unix )环境中运行R CMD INSTALL xxx。因此,如果您喜欢终端方式,还可以通过终端中的导出命令设置PKG_CPPFLAGS和PKG_LIBS,并运行R CMD INSTALL RMySQL_xxx.tar.gz从手动下载的源包中安装。
因此,下面的方法也适用于第3步的终端
$ export PKG_CPPFLAGS="-I/usr/local/include/mysql"
$ export PKG_LIBS="-L/usr/local/lib -lmysqlclient"
$ R CMD INSTALL RMySQL_0.9-3.tar.gz发布于 2014-09-13 22:28:21
我按照上述指示行事:
brew install mysql然后在RStudio中:
Sys.setenv(PKG_CPPFLAGS = "-I/usr/local/include/mysql")
Sys.setenv(PKG_LIBS = "-L/usr/local/lib -lmysqlclient")
install.packages("RMySQL", type="source")它给出了错误:
In file included from RS-MySQL.c:22:
./RS-MySQL.h:32:10: fatal error: 'mysql.h' file not found
#include <mysql.h>
^ 1 error generated.
make: *** [RS-MySQL.o] Error 1
ERROR: compilation failed for package ‘RMySQL’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL’要解决这个问题,请将RStudio中的最后一个命令更改为:
install.packages("RMySQL",
configure.args="--with-mysql-dir=/usr/local/bin/
--with-mysql-inc=/usr/local/include/mysql
--with-mysql-lib=/usr/local/lib", type="source")希望这能有所帮助。
发布于 2014-09-15 17:22:03
您将在这里中找到完整的解决方案。您可能必须根据您的系统环境进行配置。它适用于我的
https://stackoverflow.com/questions/24537257
复制相似问题