Установка пакета R - сбой компиляции gcc (XX нельзя использовать при создании общего объекта; перекомпилировать с -fPIC) - PullRequest
0 голосов
/ 18 октября 2018

Я устанавливаю nloptr пакет через консоль R.

Существует популярный вопрос, который предлагает установить nloptr через apt с использованием sudo apt-get install libnlopt-dev.Я попробовал это, но безуспешно.Если вы увидите подробное описание, вы обнаружите, что программа установки действительно обнаружила библиотеку nloptr configure: Suitable NLopt library found.

Однако, похоже, существует эта странная ошибка, которая не позволяет мне установить библиотеку.Я даже пытался установить более старые версии из пакета tar.gz, но все еще с той же ошибкой.

> install.packages('nloptr')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/nloptr_1.2.1.tar.gz'
Content type 'application/x-gzip' length 2448313 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... 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 nlopt.h usability... yes
checking nlopt.h presence... yes
checking for nlopt.h... yes
configure: Now testing for NLopt versison number.
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/PkgFlags.R
** libs
g++  -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c dummy.cpp -o dummy.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG     -I/usr/local/include  -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init_nloptr.c -o init_nloptr.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG     -I/usr/local/include  -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c nloptr.c -o nloptr.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so dummy.o init_nloptr.o nloptr.o -L/usr/local/lib -lnlopt -lm -L/usr/lib/R/lib -lR
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(general.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(optimize.o): relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(mt19937ar.o): relocation R_X86_64_TPOFF32 against `mti' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(timer.o): relocation R_X86_64_TPOFF32 against `start_inited.4227' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(cdirect.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(pnet.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(crs.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(mlsl.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(ccsa_quadratic.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(mma.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(cobyla.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(newuoa.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(nldrmd.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(sbplx.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(auglag.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(isres.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(slsqp.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(esch.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(redblack.o): relocation R_X86_64_32S against symbol `nil' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(sobolseq.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(DIRect.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libnlopt.a(DIRsubrout.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'nloptr.so' failed
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/usr/local/lib/R/site-library/nloptr’

The downloaded source packages are in
    ‘/tmp/RtmpNXGKfk/downloaded_packages’
Warning message:
In install.packages("nloptr") :
  installation of package ‘nloptr’ had non-zero exit status

Я сослался на множество вопросов SO, но не мог понять, что именно делать.Более того, файл конфигурации бесконечно большой, и я понятия не имею, где внести изменения

1 Ответ

0 голосов
/ 18 октября 2018

Благодаря комментарию @ JBGruber я нашел альтернативный обходной путь.

sudo apt-get install r-cran-nloptr

...