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
105 stars 35 forks source link

Error when deploying to shinyapps.io #113

Closed IvanM26 closed 2 years ago

IvanM26 commented 2 years ago

Hi! I have a shiny app that uses nloptr. I was able to publish the app without using nloptr. When I try to publish it with nloptr, I get the following error:

[2022-03-15T17:55:20.345993337+0000] Building R package: nloptr (2.0.0)
/mnt/packages/build /mnt
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++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=gnu++11 accepts -g... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... no
using NLopt via local cmake build on x86_64 

------------------ CMAKE NOT FOUND --------------------

CMake was not found on the PATH. Please install CMake:

 - yum install cmake          (Fedora/CentOS; inside a terminal)
 - apt install cmake          (Debian/Ubuntu; inside a terminal).
 - pacman -S cmake            (Arch Linux; inside a terminal).
 - brew install cmake         (MacOS; inside a terminal with Homebrew)
 - port install cmake         (MacOS; inside a terminal with MacPorts)

Alternatively install CMake from: <https://cmake.org/>

-------------------------------------------------------

configure: creating ./config.status
config.status: creating src/Makevars
make: Entering directory '/tmp/RtmpS1b79r/R.INSTALL8cc71e2951a/nloptr/src'
gcc -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.4/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c init_nloptr.c -o init_nloptr.o
gcc -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.4/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.4/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.4/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/opt/R/4.0.4/lib/R/lib -L/usr/local/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath -Lnlopt/lib -lnlopt -L/opt/R/4.0.4/lib/R/lib -lR
make: Leaving directory '/tmp/RtmpS1b79r/R.INSTALL8cc71e2951a/nloptr/src'
make: Entering directory '/tmp/RtmpS1b79r/R.INSTALL8cc71e2951a/nloptr/src'
make: Leaving directory '/tmp/RtmpS1b79r/R.INSTALL8cc71e2951a/nloptr/src'
Warning: unknown option ‘--vanilla’
* installing to library ‘/opt/R/4.0.4/lib/R/library’
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/bin/ld: cannot find -lnlopt
collect2: error: ld returned 1 exit status
make: *** [/opt/R/4.0.4/lib/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/opt/R/4.0.4/lib/R/library/nloptr’
################################# End Task Log ################################# 
Error: Unhandled Exception: Child Task 1117629768 failed: Error building image: Build exited with non-zero status: 1
Execution halted

By reading another Issue, this might be related to that one, because I see the line cannot find -lnlopt. My actual knowledge level is not enough to understand if I'm the one doing something wrong, so sorry if this was an error on my side! Also, first time Submitting an Issue so I apologise in advance if I'm not doing this the proper way! Any help is appreciated! Thanks!

> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.4   rsconnect_0.8.25 tools_4.0.4      curl_4.3.1       jsonlite_1.7.3  
[6] digest_0.6.29    openssl_1.4.4    renv_0.13.2      askpass_1.1  
eddelbuettel commented 2 years ago

Tough, but I fail to see where this our fault. You have an app you want to host somewhere, your hosting has particular requirements -- and you should now get in touch with your hosting provider about satisfying those requirements.

IvanM26 commented 2 years ago

Thanks for your answer! For some reason, it ended up working in a different computer (same OS) without changes on the code. I will close the Issue now.