astamm / nloptr

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

Compilation error under Ubuntu 18.04 #51

Closed renkun-ken closed 6 years ago

renkun-ken commented 6 years ago

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)
eddelbuettel commented 6 years ago

You ignore the README.md and other sources, as well as the configure log which you just quoted without reading. See the money lines:

checking for nlopt.h... no configure: Need to configure and build NLopt

You need sudo apt install libnlopt-dev after which this installs in seconds -- as eg my Travis builds for the new RcppNLoptExample do (and "seconds" means the 'install nloptr' part).

Edit: Typo fixed: libnlopt-dev

renkun-ken commented 6 years ago

Thanks, @eddelbuettel. Installing libnlopt-dev (from your travis config) solves the problem. It would be better to make it explicit in README.md.

eddelbuettel commented 6 years ago

Sorry, typo. Now fixed. Whose README.md? Jelmer has been fighting^Hexplaining this for years, switching between schemes. I am not sure why his fallback scheme failed; I prefer the external library anyway. And on some platforms (Debian, Ubuntu, ...) these are easy to have. But as I recall this also installed cleanly at work under CentOS using the fallback scheme...

renkun-ken commented 6 years ago

@eddelbuettel I mean jyypma/nloptr/README.md. If external library is not mentioned, user probably expect that the installer does everything required.