无法在R 3.0.2上安装RMySQL(ubuntu 14.04)

Got*_*tey 8 mysql ubuntu r

到目前为止,我有这个错误;

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 ‘/home/samuel/R/x86_64-pc-linux-gnu-library/3.0/RMySQL’
Warning in install.packages :
  installation of package ‘./RMySQL_0.9-3.tar.gz’ had non-zero exit status
Run Code Online (Sandbox Code Playgroud)

所以我按照1所说的说法.

我输入

export PKG_CPPFLAGS="-I</usr/include/mysql>"
export PKG_LIBS="-L</usr/lib/mysql> -lmysqlclient"
Run Code Online (Sandbox Code Playgroud)

然后再次尝试在终端上安装他们给我的命令

 R CMD INSTALL RMySQL_<version>.tar.gz
Run Code Online (Sandbox Code Playgroud)

而我得到;

checking for unistd.h... yes
checking mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I</usr/include/mysql>     -fpic  -O3 -pipe  -g  -c RS-DBI.c -o RS-DBI.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I</usr/include/mysql>     -fpic  -O3 -pipe  -g  -c RS-MySQL.c -o RS-MySQL.o
In file included from RS-MySQL.c:22:0:
RS-MySQL.h:32:19: fatal error: mysql.h: No existe el archivo o el directorio
 #include <mysql.h>
                   ^
compilation terminated.
make: *** [RS-MySQL.o] Error 1
ERROR: compilation failed for package ‘RMySQL’
Run Code Online (Sandbox Code Playgroud)

所以抬头我发现了这个建议;

安装RMySQL给出错误RS-MySQL.h:32:19:致命错误:mysql.h:没有这样的文件

并遵循它在这里所说的:

http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL

我没有这一步;

3.编辑或创建文件Renviron.site并添加包含MySQL安装位置的变量MYSQL_HOME.安装R时通常不会创建该文件,因此您可能需要自己创建.您需要将它放在R Home区域的/ etc目录下.如果您不知道它在哪里,可以在R提示符下发出R.home().您将在variable = value语法中添加名为MYSQL_HOME的变量.下面是一个例子:Renviron.site的位置:C:/PROGRA~1/R/R-2.11~1.0/etc/Renviron.site内容是:MYSQL_HOME = C:/PROGRA~1/MySQL/MYSQLS~1.0/

因为,当我在Renviron.site中,它不会让我编辑任何东西,我也不清楚我应该放在那里,无论如何,我写

MYSQL_HOME=C:/PROGRA~1/MySQL/MYSQLS~1.0/***
Run Code Online (Sandbox Code Playgroud)

但我不能保存它,它不会让我,因为它说我不允许,我不能在/ etc /中创建一个新文件或任何东西

Eri*_*ulz 15

对我来说,我只需要获得包含这些文件的正确包

sudo apt-get install libmysqlclient-dev
Run Code Online (Sandbox Code Playgroud)


小智 3

你的输入是错误的,首先去掉大于号和小于号。然后对于 MySQL include 目录运行命令:

$ mysql_config --include
Run Code Online (Sandbox Code Playgroud)

因此,如果它与您已经提供的路径相同,而不是:

export PKG_CPPFLAGS="-I</usr/include/mysql>"
Run Code Online (Sandbox Code Playgroud)

进入:

export PKG_CPPFLAGS="-I/usr/include/mysql"
Run Code Online (Sandbox Code Playgroud)

对于库路径,输入命令:

$ mysql_config --libs
Run Code Online (Sandbox Code Playgroud)

与上面相同,输入没有标志的路径,对我来说就像:

export PKG_LIBS="-L/usr/lib/x86_64-linux-gnu -lmysqlclient"
Run Code Online (Sandbox Code Playgroud)

最后在最后一个输入中代替“version”指定版本号。这些步骤应该可以解决您的问题。要在 /etc/ 目录中进行编辑和写入,您应该具有权限,如果您是管理员,则可以通过 sudo 命令执行此操作。而且你提供的路径是针对windows而不是linux的。