Code Monkey home page Code Monkey logo

nloptr's People

Contributors

aadler avatar astamm avatar eddelbuettel avatar jchiquet avatar jeroen avatar jyypma avatar konsdt avatar lbelzile avatar ondrejzacha avatar ras44 avatar rolandrmgservices avatar xdaiisu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nloptr's Issues

slow down from version 1.00 to 1.2.1

Hi Guys,

I don't know if you notice or not, but after i upgrade nloptr from 1.0.0 to 1.2.1, the nloptr takes three times longer for my use case.

  1. with nloptr_1.2.1 time (secs): user 716.99, system 1749.41, elapsed 191.01
  2. with nltopr_1.0.0 time (secs): user 513.21, system 1561.3, elapsed 67.08
    A good thing is that the final output is exactly the same from two versions of package.

I haven't created any test code for you guys to test, but if necessary, i'll create one.

I don't know if this is because of the changes in underlying nlopt C code , or some wrapper function in nloptr.

any thoughts?

Trouble with installing under FreeBSD

Dear Jelmer,
I failed to install nloprt package under FreeBSD. I have emailed to you for the same question several months ago, and you had given me a good patch to solve it. But the patch was not merged into the current version of nloptr package on github. It might affected the future version published on CRAN. Could you mind it?

   Thanks so much and best wishes,
    Xiaodong

I attach the previous email for your references.

Dear Jelmer,
Your patch for 'nloptr' is so great! I've try it under FreeBSD by your suggestion with sucessul installtion, and it works properly!

Thanks so much and best wishes,
Xiaodong

On Sun, 29 Mar 2015 20:48:23 +0200
Jelmer Ypma [email protected] wrote:

Dear Xiaodong,

Thank you for your message. I may have a patch but do not have access
to a FreeBSD system. Would you be willing to try out the patch? That
would be very helpful. The patch requires the following three steps:

  1. Change the following lines in configure.ac
    Old:
    ed -s isres/isres.c <<< $'H\n,s/sqrt(/sqrt((double) /g\nw';
    ed -s util/qsort_r.c <<< $'H\n1i\nextern "C" {\n.\nw';
    ed -s util/qsort_r.c <<< $'H\n$a\n}\n.\nw' ;
    New:
    echo $'H\n,s/sqrt(/sqrt((double) /g\nw'|ed -s isres/isres.c;
    echo $'H\n1i\nextern "C" {\n.\nw'|ed -s util/qsort_r.c;
    echo $'H\n$a\n}\n.\nw'|ed -s util/qsort_r.c; \
  2. Create a new configure file using autoconf.
  3. Check if installation of the package works.

Many thanks and best wishes,
Jelmer

On Fri, Mar 27, 2015 at 9:03 AM, 姜晓东 [email protected] wrote:

Dear Jelmer Ypma,
Your package 'nloptr' for R is important for many related packages.
I found it can not be installed in FreeBSD, in which Bourne Shell but bash is the default shell. When installing nloptr in R of FreeBSD, such error messages appeared:

./configure: 3314: Syntax error: redirection unexpected (expecting word)
./configure: 3313: Syntax error: Error in command substitution
ERROR: configuration failed for package ‘nloptr’

  • removing ‘/usr/home/jxd/R/amd64-portbld-freebsd10.0-library/3.0/nloptr’

    When I changed the first line of configure in nloptr tar file from "#!/bin/sh" to "#!/usr/local/bin/bash", package 'nloptr' could be manually installed by "R CMD INSTALL" sucessfully.

    So, I guess some bash-specific syntax was used in the line 3313-3314 of file 'configure', which is normal under Linux but failed under FreeBSD.

    Could you fix it for Bourne-Shell systems such as FreeBSD?

With best regards,
Xiaodong Jiang

State Key Laboratory of Medical Neurobiology,
Fudan University, Shanghai, China.

Argument parsing in nloptr(, ...)

Line 69 of nloptr has stop(...) if arguments passed to a function are not required by that function. Should it not rather use warnings()?

For example eval_f might require an additional argument named a, while eval_g_ineq might require an additional argument named b, but not a.

[FR] Is it possible to have an Rcpp interface?

Hi, @jyypma , as we all know, there're overheads to call R functions. nloptr uses pure R functions as it's target function may jeopardize the performance for large-scale computing.

nlopt itself contains a c++ interface, in the header nlopt.hpp. So I'm asking if there's a way to share the header and provide a linkage so that we can write some nice Rcpp codes like the following example.

Thanks.

(Here's a simple use example I take from https://nlopt.readthedocs.io/en/latest/NLopt_Tutorial/#example-in-c with slight modification)

#include <Rcpp.h>
#include <nlopt.hpp>

// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(nloptr)]]
struct my_constraint_data
{
    double a;
    double b;
};

double myvfunc(const std::vector<double> &x, std::vector<double> &grad, void *my_func_data)
{
    if (!grad.empty()) {
        grad[0] = 0.0;
        grad[1] = 0.5 / sqrt(x[1]);
    }
    return sqrt(x[1]);
}


double myvconstraint(const std::vector<double> &x, std::vector<double> &grad, void *data)
{
    my_constraint_data *d = reinterpret_cast<my_constraint_data*>(data);
    double a = d->a, b = d->b;
    if (!grad.empty()) {
        grad[0] = 3 * a * (a*x[0] + b) * (a*x[0] + b);
        grad[1] = -1.0;
    }
    return ((a*x[0] + b) * (a*x[0] + b) * (a*x[0] + b) - x[1]);
}

// [[Rcpp::export]]
double test()
{
    nlopt::opt opt(nlopt::LD_MMA, 2);
    std::vector<double> lb(2);
    lb[0] = R_NegInf;
    lb[1] = 0.0;
    opt.set_lower_bounds(lb);
    opt.set_min_objective(myvfunc, NULL);
    my_constraint_data data[2] = { {2,0}, {-1,1} };
    opt.add_inequality_constraint(myvconstraint, &data[0], 1e-8);
    opt.add_inequality_constraint(myvconstraint, &data[1], 1e-8);
    
    opt.set_xtol_rel(1e-4);
    std::vector<double> x(2);
    x[0] = 1.234; 
    x[1] = 5.678;
    double minf;
    nlopt::result result = opt.optimize(x, minf);
    Rcpp::Rcout << int(result) << "\n";
    return minf;
}

Shipping the nlopt headers with nloptr

Hi,

I am working on a C++ library that uses NLopt and I am also developing an R interface.

Because only the .so is currently shipped in libs, the only solution that I see is to include the following to the package's Makevars:

PKG_CPPFLAGS = -I../inst/include -I"$(NLOPT_HOME)/include"
PKG_LIBS     = -L"$(NLOPT_HOME)/lib" -lnlopt  

where NLOPT_HOME is the address of my local install, which works fine.

However, I think that it would be fare more convenient to ship the headers along with the .so, in order to be able to simply include the following to the package's DESCRIPTION:

LinkingTo: 
    nloptr

What do you think?

Installation issue: Configuration failed on R 3.6.3 on Mac OS

I got this error when I tried to install nloptr from CRAN using install.packages("nloptr"):

make[3]: Nothing to be done for `install-exec-am'.
.././install-sh -c -d '/private/var/folders/3q/w0svc8157797sgh87crz026m0000gn/T/RtmpyJVPSM/R.INSTALL14267c1e3cba/nloptr/src/nlopt_src/include'
/bin/sh: .././install-sh: Permission denied
make[3]: *** [install-includeHEADERS] Error 1
make[2]: *** [install-am] Error 2
make[1]: *** [install] Error 2
make: *** [install-recursive] Error 1
ERROR: configuration failed for package ‘nloptr’

I got around this by using devtools::install_github("jyypma\nloptr") works but I was wondering if there's a different way to get the CRAN installation to work on Mac's.

install on centos

Hello,

I'm trying to install on a CENTOS computer and it keeps failing with the following message. Can you help?

Error installing package 'nloptr':
==================================

* installing to library ‘/tmp/RtmpFit0r9/renv-staging-368179e7bd51’
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
make: *** No rule to make target `clean'.  Stop.
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++ -m64 -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -m64 -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -m64 -std=gnu++11 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... /usr/bin/grep
checking for egrep... /usr/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... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to configure and build NLopt
configure: Starting to install library to /tmp/RtmpFit0r9/renv-package-368170f945b0/nloptr/src/nlopt_src
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc -m64 -std=gnu99
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 gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking whether gcc -m64 -std=gnu99 understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc -m64 -std=gnu99... gcc3
checking for gcc -m64 -std=gnu99 option to accept ISO C99... none needed
checking for gcc -m64 -std=gnu99 option to accept ISO Standard C... (cached) none needed
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc -m64 -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ERROR: no information for variable 'RANLIB'
checking command to parse /usr/bin/nm -B output from gcc -m64 -std=gnu99 object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -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 for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -m64 -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -m64 -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -m64 -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -m64 -std=gnu99 static flag -static works... no
checking if gcc -m64 -std=gnu99 supports -c -o file.o... yes
checking if gcc -m64 -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -m64 -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -m64 -std=gnu++11 accepts -g... yes
checking dependency style of g++ -m64 -std=gnu++11... gcc3
checking how to run the C++ preprocessor... g++ -m64 -std=gnu++11 -E
checking for ld used by g++ -m64 -std=gnu++11... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ -m64 -std=gnu++11 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ -m64 -std=gnu++11 option to produce PIC... -fPIC -DPIC
checking if g++ -m64 -std=gnu++11 PIC flag -fPIC -DPIC works... yes
checking if g++ -m64 -std=gnu++11 static flag -static works... no
checking if g++ -m64 -std=gnu++11 supports -c -o file.o... yes
checking if g++ -m64 -std=gnu++11 supports -c -o file.o... (cached) yes
checking whether the g++ -m64 -std=gnu++11 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for ANSI C header files... (cached) yes
checking whether time.h and sys/time.h may both be included... yes
checking for unistd.h... (cached) yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking for stdint.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for C thread-local keyword... __thread
checking size of unsigned int... 4
checking size of unsigned long... 8
checking for uint32_t... yes
checking for sin in -lm... yes
checking for BSDgettimeofday... no
checking for gettimeofday... yes
checking for time... yes
checking for qsort_r... yes
checking for getpid... yes
checking for gettid syscall... yes
checking for isnan... yes
checking for isinf... yes
checking for copysign... yes
checking for mkoctfile... no
checking for mex... mex
checking for working HUGE_VAL... ok
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating nlopt.pc
config.status: creating api/Makefile
config.status: creating util/Makefile
config.status: creating octave/Makefile
config.status: creating direct/Makefile
config.status: creating cdirect/Makefile
config.status: creating stogo/Makefile
config.status: creating praxis/Makefile
config.status: creating luksan/Makefile
config.status: creating crs/Makefile
config.status: creating mlsl/Makefile
config.status: creating mma/Makefile
config.status: creating cobyla/Makefile
config.status: creating newuoa/Makefile
config.status: creating neldermead/Makefile
config.status: creating auglag/Makefile
config.status: creating bobyqa/Makefile
config.status: creating isres/Makefile
config.status: creating slsqp/Makefile
config.status: creating esch/Makefile
config.status: creating test/Makefile
config.status: creating swig/Makefile
config.status: creating swig/nlopt.scm
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory `/tmp/RtmpFit0r9/renv-package-368170f945b0/nloptr/src/nlopt_src'
Making all in util
make[2]: Entering directory `/tmp/RtmpFit0r9/renv-package-368170f945b0/nloptr/src/nlopt_src/util'
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT mt19937ar.lo -MD -MP -MF .deps/mt19937ar.Tpo -c -o mt19937ar.lo mt19937ar.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT mt19937ar.lo -MD -MP -MF .deps/mt19937ar.Tpo -c mt19937ar.c  -fPIC -DPIC -o .libs/mt19937ar.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT mt19937ar.lo -MD -MP -MF .deps/mt19937ar.Tpo -c mt19937ar.c -o mt19937ar.o >/dev/null 2>&1
mv -f .deps/mt19937ar.Tpo .deps/mt19937ar.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT sobolseq.lo -MD -MP -MF .deps/sobolseq.Tpo -c -o sobolseq.lo sobolseq.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT sobolseq.lo -MD -MP -MF .deps/sobolseq.Tpo -c sobolseq.c  -fPIC -DPIC -o .libs/sobolseq.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT sobolseq.lo -MD -MP -MF .deps/sobolseq.Tpo -c sobolseq.c -o sobolseq.o >/dev/null 2>&1
mv -f .deps/sobolseq.Tpo .deps/sobolseq.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c -o timer.lo timer.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c timer.c  -fPIC -DPIC -o .libs/timer.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c timer.c -o timer.o >/dev/null 2>&1
mv -f .deps/timer.Tpo .deps/timer.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c -o stop.lo stop.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c stop.c  -fPIC -DPIC -o .libs/stop.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c stop.c -o stop.o >/dev/null 2>&1
mv -f .deps/stop.Tpo .deps/stop.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT redblack.lo -MD -MP -MF .deps/redblack.Tpo -c -o redblack.lo redblack.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT redblack.lo -MD -MP -MF .deps/redblack.Tpo -c redblack.c  -fPIC -DPIC -o .libs/redblack.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT redblack.lo -MD -MP -MF .deps/redblack.Tpo -c redblack.c -o redblack.o >/dev/null 2>&1
mv -f .deps/redblack.Tpo .deps/redblack.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT qsort_r.lo -MD -MP -MF .deps/qsort_r.Tpo -c -o qsort_r.lo qsort_r.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT qsort_r.lo -MD -MP -MF .deps/qsort_r.Tpo -c qsort_r.c  -fPIC -DPIC -o .libs/qsort_r.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT qsort_r.lo -MD -MP -MF .deps/qsort_r.Tpo -c qsort_r.c -o qsort_r.o >/dev/null 2>&1
mv -f .deps/qsort_r.Tpo .deps/qsort_r.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c -o rescale.lo rescale.c
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c rescale.c  -fPIC -DPIC -o .libs/rescale.o
libtool: compile:  g++ -m64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c rescale.c -o rescale.o >/dev/null 2>&1
mv -f .deps/rescale.Tpo .deps/rescale.Plo
/bin/sh ../libtool  --tag=CC   --mode=link g++ -m64 -std=gnu++11  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic   -o libutil.la  mt19937ar.lo sobolseq.lo timer.lo stop.lo redblack.lo qsort_r.lo rescale.lo  -lm 
libtool: link: ERROR: no information for variable 'AR' cru .libs/libutil.a .libs/mt19937ar.o .libs/sobolseq.o .libs/timer.o .libs/stop.o .libs/redblack.o .libs/qsort_r.o .libs/rescale.o 
../libtool: line 1102: ERROR:: command not found
make[2]: *** [libutil.la] Error 127
make[2]: Leaving directory `/tmp/RtmpFit0r9/renv-package-368170f945b0/nloptr/src/nlopt_src/util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/RtmpFit0r9/renv-package-368170f945b0/nloptr/src/nlopt_src'
make: *** [all] Error 2
ERROR: configuration failed for package ‘nloptr’
* removing ‘/tmp/RtmpFit0r9/renv-staging-368179e7bd51/nloptr’
Error: install of package 'nloptr' failed
Traceback (most recent calls last):
13: install.packages("afex")
12: install(pkgs)
11: renv_install(records)
10: renv_install_staged(records)
 9: renv_install_default(records)
 8: handler(package, renv_install_impl(record))
 7: renv_install_impl(record)
 6: withCallingHandlers(renv_install_package_local(record), error = function(e) {
        vwritef("\tFAILED")
        writef(e$output)
    })
 5: renv_install_package_local(record)
 4: renv_install_package_local_impl(package, path)
 3: r_cmd_install(package, path)
 2: r_exec_error(package, output, "install")
 1: stop(error)

Use of ellipsis (...)

Hi,
I get an error message when I run the following code:

minfun <- function(fun,x,...) return(-fun(x = x,...))
gg <- function(x,a) {-x^2 + a}
nloptr::nloptr(x0 = 3,eval_f = minfun,opts = list('algorithm' = 'NLOPT_LN_SBPLX'),fun = gg, a = 1)

Error in .checkfunargs(eval_f, arglist, "eval_f") :
eval_f requires argument 'x' but this has not been passed to the 'nloptr' function.

Evidently, x should not be provided because it should be optimized.

I have no problems with minfun using the subplex package:

subplex::subplex(par = 3,fn = minfun,fun = gg,a = 1)

So, I feel the check that causes the error message is not entirely compatible with the use of ... ?

Cannot install from source under macOS + clang6

The latest CRAN release of nloptr does not compile with R 3.5.1 under macOS 10.14 and clang6 (suggested at https://cloud.r-project.org/bin/macosx/tools)

* 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 /usr/local/clang6/bin/clang++ accepts -g... yes
checking how to run the C++ preprocessor... /usr/local/clang6/bin/clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether /usr/local/clang6/bin/clang++ 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... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
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... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to configure and build NLopt
configure: Starting to install library to /private/var/folders/dh/6nhw4l5x0sq0wqgwh346fwjm0000gn/T/RtmpMnCyKX/R.INSTALL58f477c63e96/nloptr/src/nlopt_src
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
hybrid.c:91:12: warning: 'nlopt_minimize' is deprecated [-Wdeprecated-declarations]
     ret = nlopt_minimize(p->local_alg, n, fcount, p, 
           ^
../api/nlopt.h:337:35: note: 'nlopt_minimize' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
../api/nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
1 warning generated.
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
newuoa.c:184:9: warning: 'nlopt_minimize_constrained' is deprecated [-Wdeprecated-declarations]
         ret = nlopt_minimize_constrained(NLOPT_LD_MMA, *n, quad_model, &qmd,
               ^
../api/nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
../api/nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
newuoa.c:1241:10: warning: 'nlopt_minimize_constrained' is deprecated [-Wdeprecated-declarations]
         return nlopt_minimize_constrained(NLOPT_LD_MMA, *n, lag, &ld,
                ^
../api/nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
../api/nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
2 warnings generated.
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
general.c:134:38: warning: 'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost(). [-Wdeprecated-declarations]
     nlopt_srand(nlopt_time_seed() + my_gettid() * 314159);
                                     ^
general.c:116:23: note: expanded from macro 'my_gettid'
#  define my_gettid() syscall(SYS_gettid)
                      ^
/usr/include/unistd.h:745:6: note: 'syscall' has been explicitly marked deprecated here
int      syscall(int, ...);
         ^
1 warning generated.
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from f77api.c:103:
./f77funcs.h:57:14: warning: 'nlopt_minimize_constrained' is deprecated [-Wdeprecated-declarations]
     *info = nlopt_minimize_constrained((nlopt_algorithm) *algorithm, 
             ^
./nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:103:
./f77funcs.h:96:6: warning: 'nlopt_get_local_search_algorithm' is deprecated [-Wdeprecated-declarations]
     nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
     ^
./nlopt.h:365:25: note: 'nlopt_get_local_search_algorithm' has been explicitly marked deprecated here
                                             int *maxeval) NLOPT_DEPRECATED;
                                                           ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:103:
./f77funcs.h:104:6: warning: 'nlopt_set_local_search_algorithm' is deprecated [-Wdeprecated-declarations]
     nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
     ^
./nlopt.h:368:24: note: 'nlopt_set_local_search_algorithm' has been explicitly marked deprecated here
                                             int maxeval) NLOPT_DEPRECATED;
                                                          ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:103:
./f77funcs.h:109:13: warning: 'nlopt_get_stochastic_population' is deprecated [-Wdeprecated-declarations]
     *pop = nlopt_get_stochastic_population();
            ^
./nlopt.h:370:57: note: 'nlopt_get_stochastic_population' has been explicitly marked deprecated here
NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
                                                        ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:103:
./f77funcs.h:113:6: warning: 'nlopt_set_stochastic_population' is deprecated [-Wdeprecated-declarations]
     nlopt_set_stochastic_population(*pop);
     ^
./nlopt.h:371:61: note: 'nlopt_set_stochastic_population' has been explicitly marked deprecated here
NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
                                                            ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:114:
./f77funcs.h:57:14: warning: 'nlopt_minimize_constrained' is deprecated [-Wdeprecated-declarations]
     *info = nlopt_minimize_constrained((nlopt_algorithm) *algorithm, 
             ^
./nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:114:
./f77funcs.h:96:6: warning: 'nlopt_get_local_search_algorithm' is deprecated [-Wdeprecated-declarations]
     nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
     ^
./nlopt.h:365:25: note: 'nlopt_get_local_search_algorithm' has been explicitly marked deprecated here
                                             int *maxeval) NLOPT_DEPRECATED;
                                                           ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:114:
./f77funcs.h:104:6: warning: 'nlopt_set_local_search_algorithm' is deprecated [-Wdeprecated-declarations]
     nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
     ^
./nlopt.h:368:24: note: 'nlopt_set_local_search_algorithm' has been explicitly marked deprecated here
                                             int maxeval) NLOPT_DEPRECATED;
                                                          ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:114:
./f77funcs.h:109:13: warning: 'nlopt_get_stochastic_population' is deprecated [-Wdeprecated-declarations]
     *pop = nlopt_get_stochastic_population();
            ^
./nlopt.h:370:57: note: 'nlopt_get_stochastic_population' has been explicitly marked deprecated here
NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
                                                        ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:114:
./f77funcs.h:113:6: warning: 'nlopt_set_stochastic_population' is deprecated [-Wdeprecated-declarations]
     nlopt_set_stochastic_population(*pop);
     ^
./nlopt.h:371:61: note: 'nlopt_set_stochastic_population' has been explicitly marked deprecated here
NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
                                                            ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:129:
./f77funcs.h:57:14: warning: 'nlopt_minimize_constrained' is deprecated [-Wdeprecated-declarations]
     *info = nlopt_minimize_constrained((nlopt_algorithm) *algorithm, 
             ^
./nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:129:
./f77funcs.h:96:6: warning: 'nlopt_get_local_search_algorithm' is deprecated [-Wdeprecated-declarations]
     nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
     ^
./nlopt.h:365:25: note: 'nlopt_get_local_search_algorithm' has been explicitly marked deprecated here
                                             int *maxeval) NLOPT_DEPRECATED;
                                                           ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:129:
./f77funcs.h:104:6: warning: 'nlopt_set_local_search_algorithm' is deprecated [-Wdeprecated-declarations]
     nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
     ^
./nlopt.h:368:24: note: 'nlopt_set_local_search_algorithm' has been explicitly marked deprecated here
                                             int maxeval) NLOPT_DEPRECATED;
                                                          ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:129:
./f77funcs.h:109:13: warning: 'nlopt_get_stochastic_population' is deprecated [-Wdeprecated-declarations]
     *pop = nlopt_get_stochastic_population();
            ^
./nlopt.h:370:57: note: 'nlopt_get_stochastic_population' has been explicitly marked deprecated here
NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
                                                        ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
In file included from f77api.c:129:
./f77funcs.h:113:6: warning: 'nlopt_set_stochastic_population' is deprecated [-Wdeprecated-declarations]
     nlopt_set_stochastic_population(*pop);
     ^
./nlopt.h:371:61: note: 'nlopt_set_stochastic_population' has been explicitly marked deprecated here
NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
                                                            ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
15 warnings generated.
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang-6.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
testopt.cpp:218:11: warning: 'nlopt_minimize' is deprecated [-Wdeprecated-declarations]
    ret = nlopt_minimize(algorithm,
          ^
../api/nlopt.h:337:35: note: 'nlopt_minimize' has been explicitly marked deprecated here
     int maxeval, double maxtime) NLOPT_DEPRECATED;
                                  ^
../api/nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                          ^
1 warning generated.
make[2]: *** No rule to make target `nlopt-guile.cpp', needed by `all'.  Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
/bin/sh: .././install-sh: Permission denied
make[3]: *** [install-includeHEADERS] Error 1
make[2]: *** [install-am] Error 2
make[1]: *** [install] Error 2
make: *** [install-recursive] Error 1
./configure: line 3333: checking: command not found
configure: Done installing library to /private/var/folders/dh/6nhw4l5x0sq0wqgwh346fwjm0000gn/T/RtmpMnCyKX/R.INSTALL58f477c63e96/nloptr/src/nlopt_src
cp: src/nlopt_src/include/*: No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/PkgFlags.R
** libs
/usr/local/clang6/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c dummy.cpp -o dummy.o
/usr/local/clang6/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2  -I/private/var/folders/dh/6nhw4l5x0sq0wqgwh346fwjm0000gn/T/RtmpMnCyKX/R.INSTALL58f477c63e96/nloptr/src/nlopt_src/include -fPIC  -Wall -g -O2  -c init_nloptr.c -o init_nloptr.o
init_nloptr.c:35:10: fatal error: 'nlopt.h' file not found
#include "nlopt.h"
         ^~~~~~~~~
1 error generated.
make: *** [init_nloptr.o] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/nloptr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

Failure while including nloptrAPI.h

(possibly related to #54 )

I am using nlopt in an R package, directly nlopt functions in my C++, with Rcpp and RcppArmadillo. However, it requires a system version of nlopt to be installed. So I would be happy for portability rely on nloptr and nloptrAPI.h not to rely on any system requirement. Also, it would be easier for my to put my package on CRAN.

nloptrAPI.h seems to work on simple example as can be seen for instance in https://github.com/jchiquet/RcppArmadilloNLoptExample/tree/master/nloptC/src

In https://github.com/jchiquet/PLNmodels/tree/nloptrAPI,
I am trying such an option in a slightly more "complex" setup, with several header inclusions, and I am not able to make it work... I have the following error why building, and I do not known if I am not including correctly my headers (sorry if it all about this), or if there are some conflicts at some point between the inclusion. Any help would be great! Thanks in advance.

In file included from /usr/include/c++/7/bits/locale_facets_nonio.h:2011:0,
                 from /usr/include/c++/7/locale:41,
                 from /usr/include/c++/7/iomanip:43,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/RcppCommon.h:52,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadilloForward.h:26,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadillo.h:31,
                 from utils.h:5,
                 from gradients.h:4,
                 from gradients.cpp:1:
/usr/include/c++/7/bits/codecvt.h:215:45: error: macro "length" passed 4 arguments, but takes just 1
       const extern_type* __end, size_t __max) const
                                             ^
In file included from /usr/include/c++/7/fstream:1081:0,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/armadillo:30,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadilloForward.h:46,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadillo.h:31,
                 from utils.h:5,
                 from gradients.h:4,
                 from gradients.cpp:1:
/usr/include/c++/7/bits/fstream.tcc:911:60: error: macro "length" passed 4 arguments, but takes just 1
                                this->gptr() - this->eback());
                                                            ^
/usr/include/c++/7/bits/fstream.tcc:1028:39: error: macro "length" passed 4 arguments, but takes just 1
           this->gptr() - this->eback());
                                       ^
In file included from /usr/include/c++/7/bits/locale_facets_nonio.h:2011:0,
                 from /usr/include/c++/7/locale:41,
                 from /usr/include/c++/7/iomanip:43,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/RcppCommon.h:52,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadilloForward.h:26,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadillo.h:31,
                 from utils.h:5,
                 from gradients.h:4,
                 from gradients.cpp:1:
/usr/include/c++/7/bits/codecvt.h:214:7: error: expected ‘;’ at end of member declaration
       length(state_type& __state, const extern_type* __from,
       ^~~~~~
/usr/include/c++/7/bits/codecvt.h:216:7: error: expected unqualified-id before ‘{’ token
       { return this->do_length(__state, __from, __end, __max); }
       ^
In file included from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp.h:69:0,
                 from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/RcppArmadillo/include/RcppArmadillo.h:34,
                 from utils.h:5,
                 from gradients.h:4,
                 from gradients.cpp:1:
/home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp/Nullable.h: In instantiation of ‘bool Rcpp::Nullable<T>::Rf_isNull() const [with T = Rcpp::Vector<14, Rcpp::PreserveStorage>]’:
/home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp/Nullable.h:117:28:   required from ‘bool Rcpp::Nullable<T>::isNotNull() const [with T = Rcpp::Vector<14, Rcpp::PreserveStorage>]’
/home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp/sugar/functions/sample.h:403:25:   required from here
/home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp/Nullable.h:108:29: error: no matching function for call to ‘Rcpp::Nullable<Rcpp::Vector<14, Rcpp::PreserveStorage> >::Rf_isNull(SEXPREC* const&) const’
             return Rf_isNull(m_sexp);
                    ~~~~~~~~~^~~~~~~~
In file included from /home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/nloptr/include/nloptrAPI.h:35:0,
                 from utils.h:4,
                 from gradients.h:4,
                 from gradients.cpp:1:
/usr/share/R/include/Rinternals.h:1397:18: note: candidate: bool Rcpp::Nullable<T>::Rf_isNull() const [with T = Rcpp::Vector<14, Rcpp::PreserveStorage>]
 #define isNull   Rf_isNull
                  ^
/home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp/Nullable.h:106:21: note: in expansion of macro ‘isNull’
         inline bool isNull() const {
                     ^
/usr/share/R/include/Rinternals.h:1397:18: note:   candidate expects 0 arguments, 1 provided
 #define isNull   Rf_isNull
                  ^
/home/jchiquet/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/Rcpp/Nullable.h:106:21: note: in expansion of macro ‘isNull’
         inline bool isNull() const {
                     ^
/usr/lib/R/etc/Makeconf:172: recipe for target 'gradients.o' failed

nloptr can't find nloptrAPI.h

When I attempt to run the nloptr unit tests, I get a compilation error because the compiler can't find nloptrAPI.h. nloptrAPI.h was installed in the R system environment on the relative path, lib64/R/library/nloptr/include.

When I run 'strace' to check what files are being opened, the GNU c++ compiler is not looking in the installed location for nloptrAPI.h.

Here's the strace line for the call to g++ that's problematic.

[pid 29615] execve("/bin/sh", ["/bin/sh", "-c", "g++ -I"/opt/work/binaries/R-3.5.2/lib64/R/include" -DNDEBUG -I/opt/work/include -I/opt/work/include -fpic -g -O2 -c file739f3fa23777.cpp -o file739f3fa23777.o"], 0x1985690 /* 94 vars */ <unfinished ...>

Shouldn't nloptr be including -I/opt/work/binaries/R-3.5.2/lib64/R/library/nloptr/include in the g++ call? Alternatively, shouldn't the install script copy nloptrAPI.h into lib64/R/include?

nloptr fails to compile

I recently upgraded to R3.5 and had to reinstall a lot of packages. nloptr failed to compile. I have tried using both the cran and github version. I have installed libnlopt-dev. I even rolled back to R3.4.4 and it still fails.

Here is the output from the cran install on 3.4. The error looks the same on 3.5 and using install_github

trying URL 'https://cloud.r-project.org/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/x-gzip' length 353957 bytes (345 KB)
==================================================
downloaded 345 KB

* installing *source* packagenloptr...
** packagenloptrsuccessfully unpacked and MD5 sums checked
checking for g++... g++
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: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++  -I/usr/share/R/include         -fpic  -O3 -pipe      -c dummy.cpp -o dummy.o
gcc -std=gnu99 -I/usr/share/R/include        -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 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 packagenloptr* removing/home/dhope/lib/R/library/nloptrThe downloaded source packages are in/tmp/RtmpFR8lK4/downloaded_packagesWarning message:
In install.packages("nloptr") :
  installation of packagenloptrhad non-zero exit status

My session info here is:

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.4.4 tools_3.4.4   

I haven't been able to find a similar issue by others so I suspect my system may be the cause, but any advice would be helpful.

bundling sources

I've repeatedly had issues with the sources at http://ab-initio.mit.edu/nlopt being unavailable. It seems to consistently break travis builds.

Is it possible to bundle the sources in the R package to avoid this? I'm sure that this has been thought of or previously discussed but lme4 and a few other widely downloaded packages depend on nloptr.

As an alternative, I might be able to get RStudio to host the sources so that we would have a more reliable link. Perhaps that could be a fallback download source in your build system.

Is there a reason why NLOPT_LD_CCSAQ is not included in nlotpr?

Hi and thanks @jyypma for providing this great R interface to nlopt.

For some particular optimization problems, I use the CCSA quadratic variant of the method of moving asymptoc (MMA) implemented in nlopt. Indeed, I found the former to be slightly more efficient than the later on some problems. It is also more flexible as a user-defined Hessian can be supplied. See the nlopt doc here about MMA and CCSAQ.

Unfortunately, when I try to call this optimizer via nloptr, I get

Error in is.nloptr(ret) : 
  Incorrect algorithm supplied. Use one of the following:
...

Any reason for not providing access to this optimizer in nloptr?

Here is a reproducible example

library('nloptr')

## Rosenbrock Banana function and gradient in separate functions
eval_f <- function(x) {
    return( 100 * (x[2] - x[1] * x[1])^2 + (1 - x[1])^2 )
}

eval_grad_f <- function(x) {
    return( c( -400 * x[1] * (x[2] - x[1] * x[1]) - 2 * (1 - x[1]),
                200 * (x[2] - x[1] * x[1])) )
}


# initial values
x0 <- c( -1.2, 1 )

opts <- list("algorithm"="NLOPT_LD_CCSAQ",
             "xtol_rel"=1.0e-8)
 
# solve Rosenbrock Banana function
res <- nloptr( x0=x0, 
               eval_f=eval_f, 
               eval_grad_f=eval_grad_f,
               opts=opts)

Thank for your time.

The Windows version seems stuck in 2.4.2

Hi.
I think I've managed to compile NLOPT 2.6.1 on Windows, notwithstanding the move to CMAKE. However, when trying to install nloptr, the makefiles still seem to be working under the old 2.4.2 assumption with the separate C++ library and all. I tried installing the binary version and it too claims it's calling NLOPT 2.4.2.

Is there any intention to update the code to allow Windows users to build from source or at least build the binaries with a current version of NLOPT?

Nelder-Mead segfault on development version

Using the GitHub version of nloptr, the following R command...

nloptr::neldermead(c(0, 1), fn = function(x) sqrt(abs(x[1])))

causes the following error (this happens with nloptr::sbplx, too):

 *** caught segfault ***
address 0x0, cause 'memory not mapped'

Traceback:
 1: .Call("NLoptR_Optimize", ret, PACKAGE = "nloptr")
 2: nloptr(x0, fn, lb = lower, ub = upper, opts = opts)
 3: nloptr::neldermead(c(0, 1), fn = function(x) sqrt(abs(x[1])))

The same error occurs when I try to use nlopt directly in C++ via Rcpp:

#include <Rcpp.h>
#include <cmath>
#include <nloptrAPI.h>

using namespace Rcpp;

double f(unsigned n, const double* x, double* grad, void* f_data) {
    return std::sqrt(std::abs(x[0]));
}
//[[Rcpp::export]]
void test_nlopt() {
    unsigned n = 2;
    double x [2] = {0,1};
    double min_f;

    nlopt_opt opt = nlopt_create(NLOPT_LN_NELDERMEAD, n);
    nlopt_set_min_objective(opt, f, NULL);
    nlopt_set_ftol_rel(opt, 0.00000002);
    nlopt_set_maxeval(opt, 1000);

    nlopt_result res = nlopt_optimize(opt, x, &min_f);

    return;
}

This error occurs even when I link directly to nlop using nloptr.h instead of nloptrAPI.h.

Using just nlopt by itself in a self-contained C++ program works without error.

I'm compiling using clang version 4.0.0.

Named starting parameter vector not named anymore after two iterations

I dont know if this is intended or not.
I like to use a named starting parameter, but the starting parameter vector is only named in the first two iteration steps. Starting with the third iteration step, the vector is not named anymore!

library(nloptr)

fr <- function(x){
	print(names(x))
	100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2
}

Start_par <- setNames(c(0.5, 0.25, 0.5),c("Hello","World","!!!"))

S <- bobyqa(Start_par, fr, lower = c(0, 0, 0), upper = c(0.5, 0.5, 0.5))

Console Output:

[1] "Hello" "World" "!!!"
[1] "Hello" "World" "!!!"
NULL
NULL
NULL
NULL
..

`.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

Hi Jelmer, I've been trying to install nloptr on Ubuntu 14.04 with R3.1, but get the following error. Would you please help me? Thanks.

  • installing source package ‘nloptr’ ...
    checking for g++... g++
    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: 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 -O3 -c dummy.cpp -o dummy.o
    gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include -fpic -O3 -c nloptr.c -o nloptr.o
    g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so dummy.o nloptr.o -L/usr/local/lib -lnlopt -lm -L/usr/lib/R/lib -lR
    /usr/bin/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/local/lib/libnlopt.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    make: *** [nloptr.so] Error 1
    ERROR: compilation failed for package ‘nloptr’
  • removing ‘/home/lionup/R/x86_64-pc-linux-gnu-library/3.1/nloptr’
    Error: Command failed (1)

nloptr duplicate symbols when using the C API

If the include <nloptrAPI.h> is made in a header file (with appropriate internal safe guards #ifndef and that this header is in turn included in various .cpp files, then the compiler (at least on macOS 10.15.4) complains that all nlopt symbols declared in the nloptrAPI.h file are duplicated. I made a minimal reproducible example by forking @eddelbuettel package here: https://github.com/astamm/rcppnloptexample. The versioned code compiles smoothly but if you uncomment the include in https://github.com/astamm/rcppnloptexample/blob/master/src/other_cpp.cpp, then the compiler complains.

Test failure on ARM64 and x86_64(v1.2.2.2)

When Rscript testthat.R on ARM64,The test fails and the following error occurs:
Loading required package: nloptr
══ Failed tests ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
── Failure (test-hs071.R:102:5): Test HS071. ───────────────────────────────────
res$solution not equal to solution.opt.
3/4 mismatches (average diff: 5.54e-06)
[2] 4.74 - 4.74 == 6.69e-06
[3] 3.82 - 3.82 == -8.73e-06
[4] 1.38 - 1.38 == 1.21e-06

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 46 ]
Error: Test failures

Optimization freezes

Hi,

I'm experiencing a problem when trying to perform a derivative free optimization using NLOPT_LN_COBYLA (code below). The optimization stops at one of the iterations and remains frozen for hours (let it run for more than 24h to make sure it wasn't computing) without throwing any error.

Has this problem ever been experienced?

Thanks
Ben

  toOpt = function(w,turnThresh,stock.data){
       tCosts(w,stock.data) * j - cPMOM(w,stock.data)
  }

  
    ineqCon = function(w,stock.data,turnThresh){
    
    rbind (cTurnover(w,turnThresh,stock.data)
           ,cSumWeights.Min(w,stock.data)
           ,cSumWeights.Max(w,stock.data)
           ,cVOL(w,stock.data)
           ,cREGION.US.Min(w,stock.data)
           ,cREGION.US.Max(w,stock.data))
    
  }
  
  resOpt <- nloptr(x0 = (max.vec + min.vec )/ 2
                   ,eval_f = toOpt
                   #,eval_g_eq = eqCon
                   ,eval_g_ineq = ineqCon
                   ,lb = min.vec
                   ,ub = max.vec
                   ,opts = list('algorithm' = 'NLOPT_LN_COBYLA',
                                #'algorithm' = 'NLOPT_GN_ORIG_DIRECT',
                                #'algorithm' = 'NLOPT_GN_ISRES',
                                'xtol_rel' = 1.0e-2,
                                'maxeval' = 2500,
                                'print_level' = 2
                                )
                   ,stock.data=res.all
                   ,turnThresh = 0.22
  )  

Install error - cannot run C++ compiled programs

I'm running MAC OS 10.13.4, have r-studio installed via conda. In r-studio, I'm trying to install a package (faraway) for which nloptr is a dependency. When it tries to install nloptr, I'm getting this error:

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... configure: error: in /private/var/folders/76/szjpgm796kb66l8d_lf87xnm0000gn/T/RtmpVqi9F1/R.INSTALL4b371b1b3c4/nloptr': configure: error: cannot run C++ compiled programs. If you meant to cross compile, use --host'.
See `config.log' for more details
ERROR: configuration failed for package ‘nloptr’

I've updated conda and my r environment, but this still persists.

Compilation error under Ubuntu 18.04

Under Ubuntu 18.04 + R 3.5.1, nloptr cannot fully compile but the package installation still continues as successful?

* 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... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to configure and build NLopt
configure: Starting to install library to /tmp/RtmpMM1rSS/R.INSTALL444d3709f0ad/nloptr/src/nlopt_src
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
hybrid.c: In function 'nlopt_result optimize_rect(double*, params*)':
hybrid.c:99:39: warning: 'nlopt_result nlopt_minimize(nlopt_algorithm, int, nlopt_func_old, void*, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
      stop->maxtime - (t - stop->start));
                                       ^
In file included from ../util/nlopt-util.h:30:0,
                 from hybrid.c:27:
../api/nlopt.h:329:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize(
                            ^~~~~~~~~~~~~~
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
newuoa.c: In function 'nlopt_result trsapp_(int*, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, const double*, const double*, const double*)':
newuoa.c:187:35: warning: 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
         0., 0., 0., xtol, 1000, 0.);
                                   ^
In file included from ../util/nlopt-util.h:30:0,
                 from newuoa.h:4,
                 from newuoa.c:33:
../api/nlopt.h:339:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize_constrained(
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
newuoa.c: In function 'nlopt_result biglag_(int*, int*, double*, double*, double*, double*, int*, int*, int*, double*, double*, double*, double*, double*, double*, double*, double*, const double*, const double*, const double*)':
newuoa.c:1244:35: warning: 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
         0., 0., 0., xtol, 1000, 0.);
                                   ^
In file included from ../util/nlopt-util.h:30:0,
                 from newuoa.h:4,
                 from newuoa.c:33:
../api/nlopt.h:339:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize_constrained(
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
deprecated.c: In function 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)':
deprecated.c:153:60: warning: 'nlopt_result nlopt_minimize_econstrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, double, double, int, double)' is deprecated [-Wdeprecated-declarations]
    xtol_rel, xtol_abs, ftol_rel, ftol_abs, maxeval, maxtime);
                                                            ^
deprecated.c:65:15: note: declared here
 NLOPT_STDCALL nlopt_minimize_econstrained(
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
deprecated.c: In function 'nlopt_result nlopt_minimize(nlopt_algorithm, int, nlopt_func_old, void*, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)':
deprecated.c:170:40: warning: 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
    xtol_rel, xtol_abs, maxeval, maxtime);
                                        ^
deprecated.c:138:15: note: declared here
 NLOPT_STDCALL nlopt_minimize_constrained(
               ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:103:0:
f77funcs.h: In function 'void nloptc_(int*, const int*, const int*, nlopt_f77_func, void*, const int*, nlopt_f77_func, char*, char*, const double*, const double*, double*, double*, const double*, const double*, const double*, const double*, const double*, const int*, const int*, const double*)':
f77funcs.h:65:24: warning: 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
      *maxeval, *maxtime);
                        ^
In file included from f77api.c:26:0:
nlopt.h:339:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize_constrained(
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:103:0:
f77funcs.h: In function 'void nlogls_(int*, int*, int*)':
f77funcs.h:96:65: warning: 'void nlopt_get_local_search_algorithm(nlopt_algorithm*, nlopt_algorithm*, int*)' is deprecated [-Wdeprecated-declarations]
      nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
                                                                 ^
In file included from f77api.c:26:0:
nlopt.h:363:20: note: declared here
 NLOPT_EXTERN(void) nlopt_get_local_search_algorithm(nlopt_algorithm *deriv,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:103:0:
f77funcs.h: In function 'void nlosls_(int*, int*, int*)':
f77funcs.h:104:64: warning: 'void nlopt_set_local_search_algorithm(nlopt_algorithm, nlopt_algorithm, int)' is deprecated [-Wdeprecated-declarations]
      nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
                                                                ^
In file included from f77api.c:26:0:
nlopt.h:366:20: note: declared here
 NLOPT_EXTERN(void) nlopt_set_local_search_algorithm(nlopt_algorithm deriv,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:103:0:
f77funcs.h: In function 'void nlogsp_(int*)':
f77funcs.h:109:45: warning: 'int nlopt_get_stochastic_population()' is deprecated [-Wdeprecated-declarations]
      *pop = nlopt_get_stochastic_population();
                                             ^
In file included from f77api.c:26:0:
nlopt.h:370:19: note: declared here
 NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:103:0:
f77funcs.h: In function 'void nlossp_(const int*)':
f77funcs.h:113:42: warning: 'void nlopt_set_stochastic_population(int)' is deprecated [-Wdeprecated-declarations]
      nlopt_set_stochastic_population(*pop);
                                          ^
In file included from f77api.c:26:0:
nlopt.h:371:20: note: declared here
 NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:114:0:
f77funcs.h: In function 'void nloptc(int*, const int*, const int*, nlopt_f77_func, void*, const int*, nlopt_f77_func, char*, char*, const double*, const double*, double*, double*, const double*, const double*, const double*, const double*, const double*, const int*, const int*, const double*)':
f77funcs.h:65:24: warning: 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
      *maxeval, *maxtime);
                        ^
In file included from f77api.c:26:0:
nlopt.h:339:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize_constrained(
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:114:0:
f77funcs.h: In function 'void nlogls(int*, int*, int*)':
f77funcs.h:96:65: warning: 'void nlopt_get_local_search_algorithm(nlopt_algorithm*, nlopt_algorithm*, int*)' is deprecated [-Wdeprecated-declarations]
      nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
                                                                 ^
In file included from f77api.c:26:0:
nlopt.h:363:20: note: declared here
 NLOPT_EXTERN(void) nlopt_get_local_search_algorithm(nlopt_algorithm *deriv,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:114:0:
f77funcs.h: In function 'void nlosls(int*, int*, int*)':
f77funcs.h:104:64: warning: 'void nlopt_set_local_search_algorithm(nlopt_algorithm, nlopt_algorithm, int)' is deprecated [-Wdeprecated-declarations]
      nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
                                                                ^
In file included from f77api.c:26:0:
nlopt.h:366:20: note: declared here
 NLOPT_EXTERN(void) nlopt_set_local_search_algorithm(nlopt_algorithm deriv,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:114:0:
f77funcs.h: In function 'void nlogsp(int*)':
f77funcs.h:109:45: warning: 'int nlopt_get_stochastic_population()' is deprecated [-Wdeprecated-declarations]
      *pop = nlopt_get_stochastic_population();
                                             ^
In file included from f77api.c:26:0:
nlopt.h:370:19: note: declared here
 NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:114:0:
f77funcs.h: In function 'void nlossp(const int*)':
f77funcs.h:113:42: warning: 'void nlopt_set_stochastic_population(int)' is deprecated [-Wdeprecated-declarations]
      nlopt_set_stochastic_population(*pop);
                                          ^
In file included from f77api.c:26:0:
nlopt.h:371:20: note: declared here
 NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:129:0:
f77funcs.h: In function 'void NLOPTC(int*, const int*, const int*, nlopt_f77_func, void*, const int*, nlopt_f77_func, char*, char*, const double*, const double*, double*, double*, const double*, const double*, const double*, const double*, const double*, const int*, const int*, const double*)':
f77funcs.h:65:24: warning: 'nlopt_result nlopt_minimize_constrained(nlopt_algorithm, int, nlopt_func_old, void*, int, nlopt_func_old, void*, ptrdiff_t, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
      *maxeval, *maxtime);
                        ^
In file included from f77api.c:26:0:
nlopt.h:339:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize_constrained(
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:129:0:
f77funcs.h: In function 'void NLOGLS(int*, int*, int*)':
f77funcs.h:96:65: warning: 'void nlopt_get_local_search_algorithm(nlopt_algorithm*, nlopt_algorithm*, int*)' is deprecated [-Wdeprecated-declarations]
      nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
                                                                 ^
In file included from f77api.c:26:0:
nlopt.h:363:20: note: declared here
 NLOPT_EXTERN(void) nlopt_get_local_search_algorithm(nlopt_algorithm *deriv,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:129:0:
f77funcs.h: In function 'void NLOSLS(int*, int*, int*)':
f77funcs.h:104:64: warning: 'void nlopt_set_local_search_algorithm(nlopt_algorithm, nlopt_algorithm, int)' is deprecated [-Wdeprecated-declarations]
      nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
                                                                ^
In file included from f77api.c:26:0:
nlopt.h:366:20: note: declared here
 NLOPT_EXTERN(void) nlopt_set_local_search_algorithm(nlopt_algorithm deriv,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:129:0:
f77funcs.h: In function 'void NLOGSP(int*)':
f77funcs.h:109:45: warning: 'int nlopt_get_stochastic_population()' is deprecated [-Wdeprecated-declarations]
      *pop = nlopt_get_stochastic_population();
                                             ^
In file included from f77api.c:26:0:
nlopt.h:370:19: note: declared here
 NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from f77api.c:129:0:
f77funcs.h: In function 'void NLOSSP(const int*)':
f77funcs.h:113:42: warning: 'void nlopt_set_stochastic_population(int)' is deprecated [-Wdeprecated-declarations]
      nlopt_set_stochastic_population(*pop);
                                          ^
In file included from f77api.c:26:0:
nlopt.h:371:20: note: declared here
 NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
testopt.cpp: In function 'int test_function(int)':
testopt.cpp:223:21: warning: 'nlopt_result nlopt_minimize(nlopt_algorithm, int, nlopt_func_old, void*, const double*, const double*, double*, double*, double, double, double, double, const double*, int, double)' is deprecated [-Wdeprecated-declarations]
     maxeval, maxtime);
                     ^
In file included from testopt.cpp:44:0:
../api/nlopt.h:329:28: note: declared here
 NLOPT_EXTERN(nlopt_result) nlopt_minimize(
                            ^~~~~~~~~~~~~~
make[2]: *** No rule to make target 'nlopt-guile.cpp', needed by 'all'.  Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
make[1]: *** No rule to make target 'nlopt-guile.cpp', needed by 'install'.  Stop.
make: *** [install-recursive] Error 1
./configure: line 3333: checking: command not found
configure: Done installing library to /tmp/RtmpMM1rSS/R.INSTALL444d3709f0ad/nloptr/src/nlopt_src
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-oNcpyf/r-base-3.5.1=. -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     -g -O2 -fdebug-prefix-map=/build/r-base-oNcpyf/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/tmp/RtmpMM1rSS/R.INSTALL444d3709f0ad/nloptr/src/nlopt_src/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oNcpyf/r-base-3.5.1=. -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     -g -O2 -fdebug-prefix-map=/build/r-base-oNcpyf/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/tmp/RtmpMM1rSS/R.INSTALL444d3709f0ad/nloptr/src/nlopt_src/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oNcpyf/r-base-3.5.1=. -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 -lm -lm /tmp/RtmpMM1rSS/R.INSTALL444d3709f0ad/nloptr/src/nlopt_src/lib/libnlopt_cxx.a -L/usr/lib/R/lib -lR
installing to /home/renkun/R/x86_64-pc-linux-gnu-library/3.5/nloptr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (nloptr)

another mistake in the reference manual (p. 30)

According to the reference manual (page 30), functions eval_g_ineq and eval_g_eq may return a list with two elements named "objective" and "jacobian". However, it is clear from the code in nloptr.R:117 and nloptr.R:149 that the elements in the list must be named "constraints" and "jacobian".

Unable to install nloptr due to no information for variable 'AR'

Hi,
I tired to install nloptr but failed. Here is my installation command lines:

install.packages("nloptr")

The following is my error report:

libtool: link: ERROR: no information for variable 'AR' cru .libs/libutil.a .libs/mt19937ar.o .libs/sobolseq.o .libs/timer.o .libs/stop.o .libs/redblack.o .libs/qsort_r.o .libs/rescale.o 
../libtool: line 1102: ERROR:: command not found
make[2]: *** [libutil.la] Error 127
make[2]: Leaving directory `/tmp/RtmpgIqKKE/R.INSTALL1015c5005908c/nloptr/src/nlopt_src/util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/RtmpgIqKKE/R.INSTALL1015c5005908c/nloptr/src/nlopt_src'
make: *** [all] Error 2
ERROR: configuration failed for package 'nloptr'
* removing '/public/home/shipy3/software/R/library/nloptr'

And here is the information of my R session:

R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
[1] C

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

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        magrittr_1.5      usethis_1.5.1     devtools_2.2.1   
 [5] pkgload_1.0.2     R6_2.4.1          rlang_0.4.7       fansi_0.4.0      
 [9] tools_3.6.0       pkgbuild_1.0.6    sessioninfo_1.1.1 cli_2.0.2        
[13] withr_2.1.2       ellipsis_0.3.0    remotes_2.1.0     assertthat_0.2.1 
[17] digest_0.6.23     rprojroot_1.3-2   crayon_1.3.4      processx_3.4.1   
[21] callr_3.4.0       fs_1.3.1          ps_1.3.0          curl_4.3         
[25] testthat_2.3.1    memoise_1.1.0     glue_1.4.2        compiler_3.6.0   
[29] desc_1.2.0        backports_1.1.5   prettyunits_1.0.2

Could anyone please tell me what is going wrong? Thanks a lot!

issues on AIX

Trying to install nloptr on AIX with R 3.2.2 compiled with gcc. I was
able to install nlopt first, and then launching R with the environment
variable CPATH=/sas/outmva/opt/include in order to make the header
file accessible.

However, I'm getting the following. Would you have any suggestions on
getting this to work? Thanks.

> install.packages('nloptr')
trying URL 'http://cran.revolutionanalytics.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/octet-stream' length 353942 bytes (345 KB)
==================================================
downloaded 345 KB

* installing *source* package 'nloptr' ...
** package 'nloptr' successfully unpacked and MD5 sums checked
checking for g++... g++
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... /opt/freeware/bin/grep
checking for egrep... /opt/freeware/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: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -I/sas/outmva/opt/lib/R/include -DNDEBUG  -I/usr/local/include
 -g -O2  -c dummy.cpp -o dummy.o
gcc -std=gnu99 -I/sas/outmva/opt/lib/R/include -DNDEBUG
-I/usr/local/include  -mno-fp-in-toc    -g -O2  -c nloptr.c -o
nloptr.o
g++ -shared -Wl,-brtl -Wl,-G -Wl,-bexpall -Wl,-bnoentry -lc
-L/usr/local/lib -o nloptr.so dummy.o nloptr.o -lm -lintl
installing to /sas/outmva/opt/lib/R/library/nloptr/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object
'/sas/outmva/opt/lib/R/library/nloptr/libs/nloptr.so':
  rtld: 0712-001 Symbol nlopt_create was referenced
      from module
/sas/outmva/opt/lib/R/library/nloptr/libs/nloptr.so(), but a runtime
definition
            of the symbol was not found.
rtld: 0712-001 Symbol nlopt_set_stopval was referenced
      from module
/sas/outmva/opt/lib/R/library/nloptr/libs/nloptr.so(), but a runtime
definition
            of the symbol was not found.
rtld: 0712-001 Symbol nlopt_set_ftol_rel was referenced
      from module
/sas/outmva/opt/lib/R/library/nloptr/libs/nloptr.so(), but a runtime
definition
            of the symbol was not found.
rtld: 0712-001 Symbol nlopt_set_ftol_abs was referenced
      from module
/sas/outmva/opt/lib/R/library/nloptr/libs/nloptr.so(), but a runtime
definition
            of the symbol was not found.
rtld: 0712-001 Symbol nlopt_set_xtol_rel was referenced
      from module
/sas/outmva/opt/lib/R/library/nloptr/libs/nloptr.so(), but a runtime
definition
            of the sy
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/sas/outmva/opt/lib/R/library/nloptr'

The downloaded source packages are in
        '/tmp/Rtmp5yvama/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("nloptr") :
  installation of package 'nloptr' had non-zero exit status

Problems with nloptr 1.0.4 and R 3.3.0

Hi,

I can't install the package nloptr 1.0.4 on R 3.3.0. It always appears the following message:

> install.packages("nloptr")
Installing package into ‘/Users/fgomesbarros/Library/R/3.3/library
(as ‘lib’ is unspecified)
trying URL 'https://cran.revolutionanalytics.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/octet-stream' length 353942 bytes (345 KB)
==================================================
downloaded 345 KB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... g++
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... /usr/bin/grep
checking for egrep... /usr/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: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/bin/clang++ -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/opt/local/include    -fPIC  -pipe -Os -arch x86_64 -stdlib=libstdc++  -c dummy.cpp -o dummy.o
/usr/bin/clang -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/opt/local/include    -fPIC  -pipe -Os -arch x86_64  -c nloptr.c -o nloptr.o
/usr/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -L/opt/local/lib -Wl,-headerpad_max_install_names -o nloptr.so dummy.o nloptr.o -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so':
  dlopen(/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
  Referenced from: /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
  Expected in: flat namespace
 in /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
* restoring previous ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/rz/dp6vmb39165406h9qv69q60c0000gn/T/RtmpLvLOmn/downloaded_packages’`

My R version is 3.3.0 as you can see below:

> version
               _                           
platform       x86_64-apple-darwin12.6.0   
arch           x86_64                      
os             darwin12.6.0                
system         x86_64, darwin12.6.0        
status                                     
major          3                           
minor          3.0                         
year           2016                        
month          05                          
day            03                          
svn rev        70573                       
language       R                           
version.string R version 3.3.0 (2016-05-03)
nickname       Supposedly Educational      

Is there any tip to solve it?

I also tried to install in olders versions (2.3.3 and 2.3.4) of R and had the same issue.

Thanks in advance,
Fabio

nlopt_create not provided by nloptr

When using nloptr in another package via the C interface provided by the nloptrAPI.h file, it recently fails with the following error: nlopt_create not provided by nloptr. I see the same error is now happening here: https://github.com/jchiquet/RcppArmadilloNLoptExample. I am not sure what's going on here. Actually, it throws this error with any nloptr C registered function. Could it be something caused by the latest R release? Could you please provide a fix?

random ERROR

Hello,

I get the following error message

Error: nlopt_add_inequality_mconstraint returned NLOPT_INVALID_ARGS.
Error: Test failed: 'Test HS023.'
* Not expected: res$solution not equal to solution.opt
1/2 mismatches (average diff: 2).
First 1:
 pos x y diff
   1 3 1    2.
* Not expected: all(eval_g_ineq(res$solution)$constr <= res$options$tol_constraints_ineq) isn't true.

kind of randomly.

I tried to come up with an minimal reproducible example based on your test "test-hs023.R".
Since the error occurrence follows a Poisson distribution on my laptop

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 8 (jessie)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] nloptr_1.0.4    testthat_0.11.0

loaded via a namespace (and not attached):
[1] memoise_1.0.0 crayon_1.3.1  digest_0.6.9 

I just put your test case in a for loop.

library(testthat)
library(nloptr)

sessionInfo()

for ( i in seq_len(1000) ) {
    source("test-hs023.R")
}

Or alternative to show when the error occurs.

err <- integer(100)
for (j in 1:100) {
    print(j)
    err[j] <- tryCatch({
        for ( i in seq_len(1000) ) {
            source("test-hs023.R")
        }
    }, error=function(e) return(i))
}
hist(err)
summary(err)
sort(table(err))

I hope this helps and is reproducible.

Best Florian

configure fails: ./configure: 3314: Syntax error: redirection unexpected (expecting word)

** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... no
checking for c++... c++
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 c++ accepts -g... yes
checking how to run the C++ preprocessor... c++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether c++ 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... /usr/bin/grep
checking for egrep... /usr/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... no
checking nlopt.h presence... no
checking for nlopt.h... no
./configure: 3314: Syntax error: redirection unexpected (expecting word)
./configure: 3313: Syntax error: Error in command substitution
ERROR: configuration failed for package ‘nloptr’
* removing ‘/usr/home/yuri/R/amd64-portbld-freebsd11.0-library/3.4/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

Found on the FreeBSD 11

Issue installing nloptr with nlopt in custom directory

Hi Jelmer,

I'm having issues installing nloptr due to my organization installing the nlopt package in a custom location due to security problems with downloading and installing nlopt myself. However I can't seem to figure out how to let R know where nlopt is installed when I run install.packages. I found a similar request from a previous issue which you answered here:

If you unpack the nlopt-2.4.2.tar.gz archive and configure and install the
NLopt package, then the location of the installation should be recognized
when nloptr is installed. If the location is not automatically recognized,
you can also pass these as options to the R command that you use to install
the nloptr package (--configure-vars and --configure-args can be used to
pass the NLopt include/ and lib/ paths to nloptr).

I wasn't clear on exactly how to use the last line but this looks like it relates to my issue. I tried the command below with no luck:

>install.packages('nloptr',method='wget',lib=.libPaths()[2],dependencies=T,configure.args=c('--with-nlopt-cflags=/swd/nlopt/include','--with-nlopt-libs=/swd/nlopt/lib'))

(Omit)
checking nlopt.h usability... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz", :
cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
In addition: Warning message:
In download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz", :
cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz': HTTP status was '407 Proxy Authentication Required'
Execution halted
/bin/gtar: This does not look like a tar archive

gzip: stdin: unexpected end of file
/bin/gtar: Child returned status 1
/bin/gtar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
'/bin/gtar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to /tmp/RtmpfvriBV/R.INSTALLd23947fb5bff/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory

Ultimately my R session hangs for some time until the install finally fails. I have confirmed that the nlopt files are available on the /swd/nlopt path; I've tried reading through the configure file for more information but I'm still lost. Any help you can provide would be greatly appreciated.

Best Regards,
Garrett

trouble with Installing nloptr by locally on Ubuntu

Hi Jelmer!
I'm currently using open source (R and ubuntu) to work for my organization. The problem is that we could NOT use internet which means if I want to install some package or software, I have to download it from other pc and transfer it to the working PC. As you might know by now, I'm having trouble with installing the nloptr package on Ubuntu 12.04 with R3.1.3.

Attempt 1
I've placed 'nlopt-2.4.2.tar.gz' on 'home' folder. The reason why I did this is that because the 'configure' source code shows that it uses download.file function in R and install it from there. But since I'm not able to use internet, I located 'nlopt-2.4.2.tar.gz' on the default directory (the directory where I open up the terminal) However, I've got an error saying

trying URL 'http://ab-initio.mit.edu/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt-2.4.2.tar.gz")
...
(Omit)
...
Execution halted
/bin/tar: This does not look like a tar archive
gzip: stdin: unexpected end of file
...
(Omit)
...
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory.

Attempt 2
It seems I could just install 'nlopt' by using 'sudo make install'. But, again, it seems I have to manually change some configure settings. The problem is that I really can't figure out what kind of configure that I have to change after the installation so that 'nloptr' could install successfully. The error message that I've got was
'relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object;'

It would be great if you could share your thoughts or any ideas.

Fail of use attributes of nlopt

Hi, all:
Nlopt is a nice wheel, however, I encounter some problems. I install anaconda, Cmaker, Nlopt. Then, I can import nlopt in python. But there is nothing in nlopt. I cannot use nlopt.opt

(AttributeError: module 'nlopt' has no attribute 'opt')

How to install nloptr on a machine that does not have internet?

I am trying to install the latest version of nloptr from CRAN on a remote server that does not have network connectivity to the outside world. I have copied over the nloptr_1.0.4.tar.gz file (retrieved using download.packages) to a location on the remote server and am trying to install it using a install.packages("nloptr_1.0.4.tar.gz", repos = NULL), but obviously, it is trying to retrieve the core nlopt package from http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz, and being unable, fails with (actually it stops without exiting):

Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz",  : 
  cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
In addition: Warning message:
In download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz",  :
  unable to resolve 'ab-initio.mit.edu'
Execution halted
/bin/tar: This does not look like a tar archive

gzip: stdin: unexpected end of file
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
  '/bin/tar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to /tmp/Rtmp8zLwyt/R.INSTALLd231e290492/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory

So, I downloaded the nlopt-2.4.2.tar.gz file, and tried to place it in the location where I thought $("${R_HOME}/bin/Rscript" ${r_args} -e "download.file(url='${NLOPT_URL}', destfile='${NLOPT_TGZ}')") would try to place the file. However, neither getwd(), /tmp/ or ~ appears to be the right location, or this strategy is not working for some other reason that I do not understand.

It would be great to get either some idea on how to make this strategy of installing nloptr work, or any other ideas on how to install nloptr on a machine with no internet access.

NLOpt no longer installing

Installation of nloptr is failing on Ubuntu (and probably other platforms), because the NLOpt package has moved permanently.

Note the curl -I output below:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 301 Moved Permanently
Date: Sat, 07 Oct 2017 03:06:45 GMT
Server: Apache/2.4.10 (Debian)
Location: https://github.com/stevengj/nlopt/releases/download/nlopt-2.4.2/nlopt-2.4.2.tar.gz
Content-Type: text/html; charset=iso-8859-1

This can be fixed by changing the URL at this line:

Alternatively, you can add the method="curl" and extra=-L options to download.files to fix this. If you do that line 120 in the above file will read:

${R_HOME}/bin/Rscript" --vanilla -e "download.file(
            url='http://ab-initio.mit.edu/nlopt/nlopt-${NLOPT_VERSION}.tar.gz', 
            destfile='nlopt-${NLOPT_VERSION}.tar.gz', 
            method='curl', extra='-L')

error handling

I am using global optimization for optimizing an ODE set. While doing the optimization, some of the point would be improper and causing error for ODE. This would cause the optimization to stop. Is there any method to ignore or remove the improper point and go on optimization rather than just stop? Is there any error handling parameter for the nloptr?

Undefined Symbol nlopt_set_maxtime

Hello,

I get the below error while installing nloptr_1.0.4.tar.gz using R CMD INSTALL...

** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/lib64/RRO-8.0.2/R-3.1.2/lib64/R/library/nloptr/libs/nloptr.so':
/usr/lib64/RRO-8.0.2/R-3.1.2/lib64/R/library/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed

  • removing ‘/usr/lib64/RRO-8.0.2/R-3.1.2/lib64/R/library/nloptr’
    [mm@x01tbipapp3a ~]$

Any clues?

thanks,
Manish

Build error version 1.2.2

I am getting the following build error on upgrading nloptr from 1.2.1 to 1.2.2

ERROR: configuration failed for package ‘nloptr’

R 3.6.1
ubuntu 18.04

Full trace

Unable to compile from source under OSX 10.12.4 and R 3.4.0

Hi,

I am unfortunately unable to install nloptr from source under OSX 10.12.4:

> install_github("jyypma/nloptr")
Downloading GitHub repo jyypma/nloptr@master
from URL https://api.github.com/repos/jyypma/nloptr/zipball/master
Installing nloptr
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/rq/msshv9fx53xg75fwdfw6fdhc0000gn/T/RtmpCXaajK/devtoolsf8f976c9a622/jyypma-nloptr-c4e0fb4'  \
  --library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library'  \
  --install-tests 

* installing *source* package ‘nloptr’ ...
checking for g++... g++
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... /usr/bin/grep
checking for egrep... /usr/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
/usr/local/bin/g++-7  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c dummy.cpp -o dummy.o
/usr/local/bin/gcc-7 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include  -I/usr/local/Cellar/nlopt/HEAD-b34ffdd_2/include -fPIC  -Wall -g -O2  -c nloptr.c -o nloptr.o
/usr/local/bin/g++-7 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o nloptr.so dummy.o nloptr.o -fopenmp -lgomp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/nloptr/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/nloptr/libs/nloptr.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
  Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/nloptr/libs/nloptr.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.4/Resources/library/nloptr/libs/nloptr.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/nloptr’
Error: Command failed (1)

Note that the weird location for NLopt is due to the fact that I use a brewed install of NLopt obtained with brew install --HEAD nlopt, with --HEAD is because I need the *.cmake files to use CMake & find_package(NLopt) in another project, and brew install nlopt does not ship these *.cmake files.

In any case, I tested this install by linking it to both a C++ library and another R package (see #27), and it works fine.

Any idea?

> session_info()
Session info ----------------------------------------------------------------
 setting  value                       
 version  R version 3.4.0 (2017-04-21)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.0.143)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2017-05-22   

Installation of nloptr package failed on AIX7.2

I am trying to install R packages (R base is 3.6.1) on AIX7.2 server with no internet access. My installation with nloptr package failed and I am clueless. The whole log is attached at the bottom. Below are last few lines. Can you please help me to figure out what's wrong?
Thanks.

mv -f .deps/qsort_r.Tpo .deps/qsort_r.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -maix64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I..  -I../api   -O2 -I/opt/freeware/include -I/usr/include -D_GETDELIM -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c -o rescale.lo rescale.c
libtool: compile:  g++ -maix64 -std=gnu++11 -DHAVE_CONFIG_H -I. -I.. -I../api -O2 -I/opt/freeware/include -I/usr/include -D_GETDELIM -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c rescale.c  -DPIC -o .libs/rescale.o
mv -f .deps/rescale.Tpo .deps/rescale.Plo
/bin/sh ../libtool  --tag=CC   --mode=link g++ -maix64 -std=gnu++11  -O2 -I/opt/freeware/include -I/usr/include -D_GETDELIM   -o libutil.la  mt19937ar.lo sobolseq.lo timer.lo stop.lo redblack.lo qsort_r.lo rescale.lo  -lm 
libtool: link: ar cru .libs/libutil.a .libs/mt19937ar.o .libs/sobolseq.o .libs/timer.o .libs/stop.o .libs/redblack.o .libs/qsort_r.o .libs/rescale.o 
ar: 0707-126 .libs/mt19937ar.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
ar: 0707-126 .libs/sobolseq.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
ar: 0707-126 .libs/timer.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
ar: 0707-126 .libs/stop.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
ar: 0707-126 .libs/redblack.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
ar: 0707-126 .libs/qsort_r.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
ar: 0707-126 .libs/rescale.o is not valid with the current object file mode.
	Use the -X option to specify the desired object mode.
make[3]: *** [Makefile:371: libutil.la] Error 7
make[3]: Leaving directory '/tmp/RtmpT3pqia/R.INSTALL3d023035021285/nloptr/src/nlopt_src/util'
make[2]: *** [Makefile:574: all-recursive] Error 1
make[2]: Leaving directory '/tmp/RtmpT3pqia/R.INSTALL3d023035021285/nloptr/src/nlopt_src'
make[1]: *** [Makefile:438: all] Error 2
make[1]: Leaving directory '/tmp/RtmpT3pqia/R.INSTALL3d023035021285/nloptr/src/nlopt_src'
ERROR: configuration failed for package 'nloptr'
* removing '/software/R/site-library/nloptr'
make: *** [makefile:5: all] Error 1

nloptr.log

error building nloptr on mac

On my mac, I've installed nlopt with homebrew with the line.

brew install nlopt

The files are placed in /usr/local/Cellar/nlopt/2.4.2.

When I run

install.packages("nloptr")

I get the following errors

...
checking nlopt.h usability... yes
checking nlopt.h presence... yes
checking for nlopt.h... yes
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
clang++ -I/usr/local/Cellar/r/3.2.3/R.framework/Resources/include -DNDEBUG -I/usr/local/include  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include  -I/usr/local/include   -fPIC  -g -O2  -c dummy.cpp -o dummy.o
clang -I/usr/local/Cellar/r/3.2.3/R.framework/Resources/include -DNDEBUG -I/usr/local/include  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include  -I/usr/local/include  -I/usr/local/Cellar/nlopt/2.4.2/include -fPIC  -g -O2  -c nloptr.c -o nloptr.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/Cellar/r/3.2.3/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -o nloptr.so dummy.o nloptr.o -L/usr/local/Cellar/nlopt/2.4.2/lib -lnlopt -lm -F/usr/local/Cellar/r/3.2.3/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lnlopt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/usr/local/lib/R/3.2/site-library/nloptr’
* restoring previous ‘/usr/local/lib/R/3.2/site-library/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/x0/y0b_v56j1j79jr55r9yftj580000gn/T/RtmptXK02m/downloaded_packages’

The clang++ compilation clearly has the include and lib directories linked as per L/usr/local/Cellar/nlopt/2.4.2/lib. Help appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.