Я пытаюсь установить пакет R ‘lubridate’ на Centos 6. Поскольку lubridate требует более свежую версию g ++, чем стандартный компилятор на Centos 6, я скачал и скомпилировал версию gcc 4.9 (из того, что я читал, lubridate требует > v4.8)
Затем я добавил строки:
CXX=/opt/gcc_4.9.1/rtf/bin/g++
CC=/opt/gcc_4.9.1/rtf/bin/gcc -std=gnu99
в файл ~ / .R / Makevars, чтобы попытаться заставить его использовать более новый компилятор, но когда я пытаюсь установить lubridate, я получаю эту ошибку:
> 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:
/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):
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 на следующие:
CXX=g++
CC=gcc
Тогда похоже, что оба исполняемых файла становятся обычными системными:
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
Есть ли другой файл, который имеет приоритет над моим определенным местоположением g ++ в файле ~ / .R / Makevars? Реальный вопрос в том, как заставить R использовать /opt/gcc_4.9.1/rtf/bin/g++ здесь?
Похоже, мне нужно было установить CXX1X=/opt/gcc_4.9.1/rtf/bin/g++
в файле ~ / .R / Makevars, после этого пакет lubridate использовал намеченный g ++ и успешно скомпилировал. К сожалению, это не полностью решило мою проблему, так как R не может загрузить библиотеку:
** 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 за то, что указал мне правильное направление.
Других решений пока нет …