首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R Makevars文件未正确覆盖g++

R Makevars文件未正确覆盖g++
EN

Stack Overflow用户
提问于 2018-02-15 04:59:00
回答 1查看 1.1K关注 0票数 2

我正在尝试在Centos 6上安装R包' lubridate‘。因为lubridate需要比Centos 6上的标准编译器更新的g++版本,所以我下载并编译了gcc 4.9版(据我所读,lubridate需要>v4.8)

然后我添加了以下几行:

代码语言:javascript
复制
CXX=/opt/gcc_4.9.1/rtf/bin/g++
CC=/opt/gcc_4.9.1/rtf/bin/gcc -std=gnu99

添加到~/.R/Makevars文件中,尝试强制它使用较新的编译器,但当我尝试安装lubridate时,我收到以下错误:

代码语言:javascript
复制
> install.packages("lubridate")
trying URL 'https://cran.rstudio.com/src/contrib/lubridate_1.7.2.tar.gz'
Content type 'application/x-gzip' length 450988 bytes (440 KB)
==================================================
downloaded 440 KB

* installing *source* package ‘lubridate’ ...
** package ‘lubridate’ successfully unpacked and MD5 sums checked
** libs
g++ -std=c++0x -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"   -fpic  -g -O2 -c RcppExports.cpp -o RcppExports.o
/opt/gcc_4.9.1/rtf/bin/gcc -std=gnu99 -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -fpic  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -c datetime.c -o datetime.o
/opt/gcc_4.9.1/rtf/bin/gcc -std=gnu99 -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -fpic  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -c period.c -o period.o
/opt/gcc_4.9.1/rtf/bin/gcc -std=gnu99 -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -fpic  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -c tparse.c -o tparse.o
tparse.c: In function ‘C_parse_dt’:
tparse.c:338:26: warning: ‘oMIN’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         INTEGER(oMIN)[i] = M;
                          ^
tparse.c:337:27: warning: ‘oHOUR’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         INTEGER(oHOUR)[i] = H;
                           ^
tparse.c:336:26: warning: ‘oDAY’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         INTEGER(oDAY)[i] = d;
                          ^
tparse.c:335:28: warning: ‘oMONTH’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         INTEGER(oMONTH)[i] = m - 1;
                            ^
tparse.c:334:27: warning: ‘oYEAR’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         INTEGER(oYEAR)[i] = y - 1900;
                           ^
g++ -std=c++0x -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"   -fpic  -g -O2 -c update.cpp -o update.o
In file included from ./cctz/include/civil_time.h:18,
                 from update.cpp:3:
./cctz/include/civil_time_detail.h:37: error: expected nested-name-specifier before ‘year_t’
./cctz/include/civil_time_detail.h:37: error: ‘year_t’ has not been declared
./cctz/include/civil_time_detail.h:37: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:37: error: expected unqualified-id before ‘=’ token
./cctz/include/civil_time_detail.h:41: error: expected nested-name-specifier before ‘diff_t’
./cctz/include/civil_time_detail.h:41: error: ‘diff_t’ has not been declared
./cctz/include/civil_time_detail.h:41: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:41: error: expected unqualified-id before ‘=’ token
./cctz/include/civil_time_detail.h:46: error: expected nested-name-specifier before ‘month_t’
./cctz/include/civil_time_detail.h:46: error: ‘month_t’ has not been declared
./cctz/include/civil_time_detail.h:46: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:46: error: expected unqualified-id before ‘=’ token
./cctz/include/civil_time_detail.h:47: error: expected nested-name-specifier before ‘day_t’
./cctz/include/civil_time_detail.h:47: error: ‘day_t’ has not been declared
./cctz/include/civil_time_detail.h:47: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:47: error: expected unqualified-id before ‘=’ token
./cctz/include/civil_time_detail.h:48: error: expected nested-name-specifier before ‘hour_t’
./cctz/include/civil_time_detail.h:48: error: ‘hour_t’ has not been declared
./cctz/include/civil_time_detail.h:48: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:48: error: expected unqualified-id before ‘=’ token
./cctz/include/civil_time_detail.h:49: error: expected nested-name-specifier before ‘minute_t’
./cctz/include/civil_time_detail.h:49: error: ‘minute_t’ has not been declared
./cctz/include/civil_time_detail.h:49: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:49: error: expected unqualified-id before ‘=’ token
./cctz/include/civil_time_detail.h:50: error: expected nested-name-specifier before ‘second_t’
./cctz/include/civil_time_detail.h:50: error: ‘second_t’ has not been declared
./cctz/include/civil_time_detail.h:50: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:50: error: expected unqualified-id before ‘=��� token
./cctz/include/civil_time_detail.h:54: error: expected ‘)’ before ‘year’
./cctz/include/civil_time_detail.h:78: error: ‘cctz::detail::impl::is_leap_year’ declared as an ‘inline’ variable
./cctz/include/civil_time_detail.h:78: error: ‘year_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:78: error: expected ‘,’ or ‘;’ before ‘noexcept’
./cctz/include/civil_time_detail.h:81: error: ‘cctz::detail::impl::year_index’ declared as an ‘inline’ variable
./cctz/include/civil_time_detail.h:81: error: ‘year_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:81: error: ‘month_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:81: error: initializer expression list treated as compound expression
./cctz/include/civil_time_detail.h:81: error: expected ‘,’ or ‘;’ before ‘noexcept’
./cctz/include/civil_time_detail.h:84: error: ‘cctz::detail::impl::days_per_century’ declared as an ‘inline’ variable
./cctz/include/civil_time_detail.h:84: error: ‘year_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:84: error: ‘month_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:84: error: initializer expression list treated as compound expression
./cctz/include/civil_time_detail.h:84: error: expected ‘,’ or ‘;’ before ‘noexcept’
./cctz/include/civil_time_detail.h:88: error: ‘cctz::detail::impl::days_per_4years’ declared as an ‘inline’ variable
./cctz/include/civil_time_detail.h:88: error: ‘year_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:88: error: ‘month_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:88: error: initializer expression list treated as compound expression
./cctz/include/civil_time_detail.h:88: error: expected ‘,’ or ‘;’ before ‘noexcept’
./cctz/include/civil_time_detail.h:92: error: ‘cctz::detail::impl::days_per_year’ declared as an ‘inline’ variable
./cctz/include/civil_time_detail.h:92: error: ‘year_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:92: error: ‘month_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:92: error: initializer expression list treated as compound expression
./cctz/include/civil_time_detail.h:92: error: expected ‘,’ or ‘;’ before ‘noexcept’
./cctz/include/civil_time_detail.h:95: error: ‘cctz::detail::impl::days_per_month’ declared as an ‘inline’ variable
./cctz/include/civil_time_detail.h:95: error: ‘year_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:95: error: ‘month_t’ was not declared in this scope
./cctz/include/civil_time_detail.h:95: error: initializer expression list treated as compound expression
./cctz/include/civil_time_detail.h:95: error: expected ‘,’ or ‘;’ before ‘noexcept’
update.cpp:452: error: expected ‘}’ at end of input
update.cpp:452: error: expected ‘}’ at end of input
update.cpp:452: error: expected ‘}’ at end of input
make: *** [update.o] Error 1
ERROR: compilation failed for package ‘lubridate’
* removing ‘/opt/R/R-3.3.3/library/lubridate’
Warning in install.packages :
  installation of package ‘lubridate’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpRwMbsZ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

有趣的是,它看起来是在尝试正确使用正确的gcc:

代码语言:javascript
复制
/opt/gcc_4.9.1/rtf/bin/gcc -std=gnu99 -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -fpic  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -c datetime.c -o datetime.o

但不是正确的g++ (没有列出我在~/.R/Makevars文件中定义的完整路径):

代码语言:javascript
复制
g++ -std=c++0x -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"   -fpic  -g -O2 -c RcppExports.cpp -o RcppExports.o

如果我将~/.R/Makevars文件中的行改为:

代码语言:javascript
复制
CXX=g++
CC=gcc

然后,看起来这两个可执行文件都变成了正常的系统可执行文件:

代码语言:javascript
复制
g++ -std=c++0x -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"   -fpic  -g -O2 -c RcppExports.cpp -o RcppExports.o
gcc -I/opt/R/R-3.3.3/include -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I/usr/local/include -I"/opt/R/R-3.3.3/library/Rcpp/include"  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -fpic  -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp -c datetime.c -o datetime.o

是否有另一个文件的优先级高于我在~/.R/Makevars文件中定义的g++位置?真正的问题是如何让R在这里使用/opt/gcc_4.9.1/rtf/bin/g++?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-16 00:25:05

似乎我需要在~/.R/Makevars文件中设置CXX1X=/opt/gcc_4.9.1/rtf/bin/g++,之后lubridate包使用了预期的g++,并成功编译。不幸的是,这并没有完全解决我的问题,因为R不能加载库:

代码语言:javascript
复制
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/opt/R/R-3.3.3/library/lubridate/libs/lubridate.so':
  /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /opt/R/R-3.3.3/library/lubridate/libs/lubridate.so)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/R/R-3.3.3/library/lubridate’

看起来R正在使用/usr/lib64/libstdc++.so.6,而不是(可能?)使用/opt/gcc_4.9.1/rtf/lib64/libstdc++.so.6。但它确实解决了我在这里问的问题。如果我能弄清楚如何加载它,我会在这里发帖,以防其他人也在做同样的事情。感谢RolandASc为我指明了正确的方向。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48796089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档