C++ gcc编译器安装R包失败

C++ gcc编译器安装R包失败,c++,r,gcc,C++,R,Gcc,当gcc在R中编译lpSolve时,我收到一个“-Werror=格式安全性”错误 我正在使用Ubuntu12.04(lubuntu内核)和R版本3.1.0 下面是确切的错误: * installing *source* package ‘lpSolve’ ... ** libs gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_I

当gcc在R中编译lpSolve时,我收到一个“-Werror=格式安全性”错误

我正在使用Ubuntu12.04(lubuntu内核)和R版本3.1.0

下面是确切的错误:

   * installing *source* package ‘lpSolve’ ...
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_INTERACTIVE -DUSRDLL -DCLOCKTIME -DRoleIsExternalInvEngine -DINVERSE_ACTIVE=INVERSE_LUSOL -DINLINE=static -DParanoia     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c colamd.c -o colamd.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_INTERACTIVE -DUSRDLL -DCLOCKTIME -DRoleIsExternalInvEngine -DINVERSE_ACTIVE=INVERSE_LUSOL -DINLINE=static -DParanoia     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c commonlib.c -o commonlib.o
commonlib.c: In function ‘blockWriteINT’:
commonlib.c:691:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteBOOL’:
commonlib.c:710:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteREAL’:
commonlib.c:732:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [commonlib.o] Error 1
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_INTERACTIVE -DUSRDLL -DCLOCKTIME -DRoleIsExternalInvEngine -DINVERSE_ACTIVE=INVERSE_LUSOL -DINLINE=static -DParanoia     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c commonlib.c -o commonlib.o
commonlib.c: In function ‘blockWriteINT’:
commonlib.c:691:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteBOOL’:
commonlib.c:710:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteREAL’:
commonlib.c:732:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [commonlib.o] Error 1
ERROR: compilation failed for package ‘lpSolve’
* removing ‘/home/ben/lpSolve.Rcheck/lpSolve’
我尝试过使用R CMD安装手动安装它。我也按照指示做了,但没有用


谢谢你的关注

错误发生在函数中的fprintf处,因此如果您下载源代码,重新制作包,它就会得到解决。但是lpSolve包装目前是孤立的。由于编译器检查,可能会发生错误。这里有个绕道的方法

  • 转到R etc路径(例如/usr/lib/R/etc或/etc/R)
  • 编辑Makeconf文件:remove-Werror=CFLAGS中的格式安全性。(它是只读文件,因此需要su权限。)
  • 重新安装包:install.package('lpSolve')
  • 如有必要,恢复Makeconf文件

  • 我希望这对您有所帮助。

    考虑使用较旧的
    gcc
    ?刚才lpSolve包已经更新到了5.6.8,所以安装lpSolve包就没有问题了。可在以下位置查看更改日志: