astamm / nloptr

nloptr provides an R interface to NLopt, a free/open-source library for nonlinear optimization providing a common interface to a number of different optimization routines which can handle nonlinear constraints and lower and upper bounds for the controls.
https://astamm.github.io/nloptr/
Other
106 stars 34 forks source link

Trouble with nloptr installation - R studio; Windows 10 #110

Closed heriades closed 2 years ago

heriades commented 2 years ago

Hello,

I'm a basic R studio user. During the installation of nloptr I faced a problem as follow:

install.packages("nloptr", repos="http://cran.rstudio.com/", dependencies=TRUE) Installing package into ‘C:/Users/Asus/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified)

There is a binary version available but the source version is later: binary source needs_compilation nloptr 1.2.2.2 2.0.0 TRUE

installing the source package ‘nloptr’

trying URL 'http://cran.rstudio.com/src/contrib/nloptr_2.0.0.tar.gz[](https://github.com/stevengj)' Content type 'application/x-gzip' length 2219414 bytes (2.1 MB) downloaded 2.1 MB

installing source package 'nloptr' ... pakiet 'nloptr' został pomyślnie rozpakowany oraz sumy MD5 zostały sprawdzone using staged installation

WARNING: this package has a configure script It probably needs manual configuration

* libs rm -f nloptr.dll init_nloptr.o nloptr.o test-C-API.o test-runner.o "C:/PROGRA1/R/R-361.0/bin/x64/Rscript.exe" "../tools/winlibs.R" cp ../windows/nlopt-2.7.1/include/ ../inst/include/ C:/Rtools/mingw_64/bin/gcc -I"C:/PROGRA1/R/R-361.0/include" -DNDEBUG -I../inst/include -I"C:/Users/Asus/Documents/R/win-library/3.6/testthat/include" -O2 -Wall -std=gnu99 -mtune=generic -c init_nloptr.c -o init_nloptr.o C:/Rtools/mingw_64/bin/gcc -I"C:/PROGRA1/R/R-361.0/include" -DNDEBUG -I../inst/include -I"C:/Users/Asus/Documents/R/win-library/3.6/testthat/include" -O2 -Wall -std=gnu99 -mtune=generic -c nloptr.c -o nloptr.o C:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA1/R/R-361.0/include" -DNDEBUG -I../inst/include -I"C:/Users/Asus/Documents/R/win-library/3.6/testthat/include" -O2 -Wall -mtune=generic -c test-C-API.cpp -o test-C-API.o C:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA1/R/R-361.0/include" -DNDEBUG -I../inst/include -I"C:/Users/Asus/Documents/R/win-library/3.6/testthat/include" -O2 -Wall -mtune=generic -c test-runner.cpp -o test-runner.o In file included from C:/Users/Asus/Documents/R/win-library/3.6/testthat/include/testthat.h:1:0, from test-runner.cpp:7: C:/Users/Asus/Documents/R/win-library/3.6/testthat/include/testthat/testthat.h: In function 'std::ostream& Catch::cout()': C:/Users/Asus/Documents/R/win-library/3.6/testthat/include/testthat/testthat.h:145:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes] } ^ C:/Users/Asus/Documents/R/win-library/3.6/testthat/include/testthat/testthat.h: In function 'std::ostream& Catch::cerr()': C:/Users/Asus/Documents/R/win-library/3.6/testthat/include/testthat/testthat.h:152:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes] } ^ C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o nloptr.dll tmp.def init_nloptr.o nloptr.o test-C-API.o test-runner.o -L../windows/nlopt-2.7.1/lib/x64 -lnlopt -LC:/PROGRA1/R/R-361.0/bin/x64 -lR ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(ags.cc.obj):(.text+0xbdb): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct(unsigned long long, char)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(ags.cc.obj):(.text+0xc2e): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct(unsigned long long, char)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(ags.cc.obj):(.text+0xf09): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct(unsigned long long, char)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(ags.cc.obj):(.text+0x1261): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long long&, unsigned long long)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x2cc): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long long&, unsigned long long)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x7f0): undefined reference to std::runtime_error::runtime_error(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x15da): undefined reference to std::runtime_error::runtime_error(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x18a5): undefined reference to std::runtime_error::runtime_error(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x1926): undefined reference to std::runtime_error::runtime_error(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x1981): undefined reference to std::runtime_error::runtime_error(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text+0x2ae4): undefined reference to std::runtime_error::runtime_error(char const)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text$_ZN9gnu_cxx12__to_xstringINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_yPKS8_PcEySB_z[_ZN9gnu_cxx12__to_xstringINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_yPKS8_PcEySB_z]+0x8b): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long long&, unsigned long long)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text$ZStplIcSt11char_traitsIcESaIcEENSt7cxx1112basic_stringIT_T0_T1_EEPKS5_OS8[ZStplIcSt11char_traitsIcESaIcEENSt7cxx1112basic_stringIT_T0_T1_EEPKS5_OS8]+0x29): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_replace(unsigned long long, unsigned long long, char const, unsigned long long)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(solver.cc.obj):(.text$_ZStplIcSt11char_traitsIcESaIcEENSt7cxx1112basic_stringIT_T0_T1_EEOS8PKS5[_ZStplIcSt11char_traitsIcESaIcEENSt7cxx1112basic_stringIT_T0_T1_EEOS8PKS5]+0x35): undefined reference to std::cxx11::basic_string<char, std::char_traits, std::allocator >::_M_append(char const*, unsigned long long)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(local_optimizer.cc.obj):(.text+0x61): undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long long&, unsigned long long)' ../windows/nlopt-2.7.1/lib/x64/libnlopt.a(local_optimizer.cc.obj):(.text+0xd9): undefined reference to std::runtime_error::runtime_error(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' collect2.exe: error: ld returned 1 exit status nie utworzono pliku DLL ERROR: compilation failed for package 'nloptr'

removing 'C:/Users/Asus/Documents/R/win-library/3.6/nloptr' Warning in install.packages : installation of package ‘nloptr’ had non-zero exit status The downloaded source packages are in ‘C:\Users\Asus\AppData\Local\Temp\RtmpGGr3vt\downloaded_packages’

Could you help me with that? Cheers!

eddelbuettel commented 2 years ago

If you are on Windows, can you not just upgrade to the current version of R and enjoy the premade binary?

Otherwise, it looks like your compiler is too old. There is little we can do for you here -- there are older version of nloptr in the Archive section and you could try those given your older toolchain.

heriades commented 2 years ago

It works! Thank you very much