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

Linking problem in version 2.0.0 with Linux #97

Closed jchiquet closed 2 years ago

jchiquet commented 2 years ago

To continue the email exchange we had with @astamm ...

With the master version of nloptr (2.0.0), I experience some linking problems during R CMD check on Linux machines in packages missSBM and PLNmodels which I maintain and use nlopt.

With github actions, R CMD check passes for Window and MacOS but not ubuntu : https://github.com/GrossSBM/missSBM/actions/runs/1717379874

Note that I directly call nlopt.h in C++, and @astamm tried a PR to correct this https://github.com/GrossSBM/missSBM/commit/795daec19d1101f2d1e61dd58387aabf863a3cda

but still failing.

Locally, with Ubuntu 20.04 , "R CMD INSTALL --preclean --no-multiarch --with-keep.source missSBM" works (no system nlopt installed) but it fails during the RCMD check process :

==> devtools::check()

ℹ Updating missSBM documentation
ℹ Loading missSBM
Writing NAMESPACE
Writing NAMESPACE
── Building ─────────────────────────────────────────────── missSBM ──
Setting env vars:
• CFLAGS    : -Wall -pedantic -fdiagnostics-color=always
• CXXFLAGS  : -Wall -pedantic -fdiagnostics-color=always
• CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
──────────────────────────────────────────────────────────────────────
✓  checking for file ‘/home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM/DESCRIPTION’ ...
─  preparing ‘missSBM’: (1.3s)
✓  checking DESCRIPTION meta-information ...
─  cleaning src
─  installing the package to process help pages
─  saving partial Rd database (43.7s)
✓  creating vignettes (32.9s)
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts (338ms)
─  checking for empty or unneeded directories
   Removed empty directory ‘missSBM/tests/testthat/_snaps’
─  building ‘missSBM_1.0.2.tar.gz’

── Checking ─────────────────────────────────────────────── missSBM ──
Setting env vars:
• _R_CHECK_CRAN_INCOMING_USE_ASPELL_: TRUE
• _R_CHECK_CRAN_INCOMING_REMOTE_    : FALSE
• _R_CHECK_CRAN_INCOMING_           : FALSE
• _R_CHECK_FORCE_SUGGESTS_          : FALSE
• NOT_CRAN                          : true
── R CMD check ───────────────────────────────────────────────────────
─  using log directory ‘/home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck’
─  using R version 4.1.2 (2021-11-01)
─  using platform: x86_64-pc-linux-gnu (64-bit)
─  using session charset: UTF-8
─  using options ‘--no-manual --as-cran’
✓  checking for file ‘missSBM/DESCRIPTION’
─  checking extension type ... Package
─  this is package ‘missSBM’ version ‘1.0.2’
─  package encoding: UTF-8
✓  checking package namespace information ...
✓  checking package dependencies (1.7s)
✓  checking if this is a source package ...
✓  checking if there is a namespace
✓  checking for executable files ...
✓  checking for hidden files and directories
✓  checking for portable file names ...
✓  checking for sufficient/correct file permissions
✓  checking serialization versions ...
E  checking whether package ‘missSBM’ can be installed (42.7s)
   Installation failed.
   See ‘/home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck/00install.out’ for details.

   See
     ‘/home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck/00check.log’
   for details.

── R CMD check results ──────────────────────────── missSBM 1.0.2 ────
Duration: 45s

> checking whether package ‘missSBM’ can be installed ... ERROR
  See below...

── Install failure ───────────────────────────────────────────────────

* installing *source* package ‘missSBM’ ...
** using staged installation
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/nloptr/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/nloptr/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c SBM_bernoulli.cpp -o SBM_bernoulli.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/nloptr/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c kmeans.cpp -o kmeans.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/nloptr/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c nlopt_wrapper.cpp -o nlopt_wrapper.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/nloptr/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c packing.cpp -o packing.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -I'/home/jchiquet/R/x86_64-pc-linux-gnu-library/4.1/nloptr/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c roundProduct.cpp -o roundProduct.o
g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o missSBM.so RcppExports.o SBM_bernoulli.o kmeans.o nlopt_wrapper.o packing.o roundProduct.o -L/usr/lib/R/lib -lR
installing to /home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck/00LOCK-missSBM/00new/missSBM/libs
** R
** data
*** moving datasets to lazyload DB
** 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 from temporary location
Error: package or namespace load failed for ‘missSBM’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck/00LOCK-missSBM/00new/missSBM/libs/missSBM.so':
  /home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck/00LOCK-missSBM/00new/missSBM/libs/missSBM.so: undefined symbol: dstedc_
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/jchiquet/Documents/Work/Projects/missSBM-repos/missSBM.Rcheck/missSBM’

1 error x | 0 warnings ✓ | 0 notes ✓
Error: R CMD check found ERRORs
Execution halted

Exited with status 1.
eddelbuettel commented 2 years ago

[ A plea: If you can, please use standard commands as R CMD build ..., R CMD INSTALL ..., R CMD check ... as that is what CRAN uses. It also helps those like myself who work the same rather way rather than via those less-officiel wrapper functions ].

What you show above is mostly a linking / symbol failure. Something may have changed between the NLopt libraries, something may be due to how you are building.

But I just installed nloptr version 2.0.0 as in the repo on the Debian testing system where I run reverse depends (and which hence all I need for your packages which are part of the set).

And it installs (of course), in this case with a build of the included library source. And missSBM installs fine and tests ok as usual. No issues I can reproduce.

```sh dirk@cloud-devel:~/tmp/prrd$ R_LIBS_USER=~/tmp/lib R CMD check --no-manual --no-vignettes missSBM_1.0.1.tar.gz * using log directory ‘/home/dirk/tmp/prrd/missSBM.Rcheck’ * using R version 4.1.2 (2021-11-01) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using options ‘--no-manual --no-vignettes’ * checking for file ‘missSBM/DESCRIPTION’ ... OK * checking extension type ... Package * this is package ‘missSBM’ version ‘1.0.1’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘missSBM’ can be installed ... [133s/132s] OK * checking installed package size ... OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK * checking data for non-ASCII characters ... OK * checking LazyData ... OK * checking data for ASCII and uncompressed saves ... OK * checking line endings in C/C++/Fortran sources/headers ... OK * checking use of PKG_*FLAGS in Makefiles ... OK * checking compilation flags used ... WARNING Compilation used the following non-portable flag(s): ‘-Wno-deprecated-declarations’ ‘-Wno-maybe-uninitialized’ ‘-Wno-nonnull’ ‘-Wno-parentheses’ ‘-Wno-sign-compare’ including flag(s) suppressing warnings * checking compiled code ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK * checking examples ... [31s/31s] OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... Running ‘spelling.R’ Running ‘testthat.R’ [186s/147s] [187s/147s] OK * checking for unstated dependencies in vignettes ... OK * checking package vignettes in ‘inst/doc’ ... OK * checking running R code from vignettes ... SKIPPED * checking re-building of vignette outputs ... SKIPPED * DONE Status: 1 WARNING See ‘/home/dirk/tmp/prrd/missSBM.Rcheck/00check.log’ for details. dirk@cloud-devel:~/tmp/prrd$ ```
astamm commented 2 years ago

Following up our discussion by mail, @jchiquet can you close this issue if you solved the problem which apparently was more of an armadillo issue, maybe filing a new issue to them for completeness about eigs_sym not linking properly.