GeomScale / volesti

Practical volume computation and sampling in high dimensions
GNU Lesser General Public License v3.0
142 stars 114 forks source link

fatal error: 'minimum_ellipsoid/khach.h' file not found #271

Open rsjian opened 1 year ago

rsjian commented 1 year ago

Very similar to https://github.com/GeomScale/volesti/issues/62, I'm getting an error installing the R interface according to the current instructions: https://github.com/GeomScale/volesti/blob/227103801440cd91ab4dd6f3f71b9f5e8931d504/doc/r_interface.md?plain=1#L10-L11 error:

In file included from direct_sampling.cpp:19:
In file included from ../../include/volume/volume_sequence_of_balls.hpp:23:
../../include/convex_bodies/vpolytope.h:20:10: fatal error: 'minimum_ellipsoid/khach.h' file not found
#include <minimum_ellipsoid/khach.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
22 warnings and 1 error generated.
make: *** [direct_sampling.o] Error 1
ERROR: compilation failed for package ‘volesti’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/volesti’

my version info:

R version 4.2.3 (2023-03-15)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1
linktorahulraj commented 1 year ago

hello @vissarion , I want to work on this issue please assign me.

linktorahulraj commented 1 year ago

hello @vissarion , I want to work on this issue please assign me.

hello @vissarion , this may solve this issue, please look at it

The C++ compiler needs to be told to look at this root path instead of /usr/include. This can be done by setting the CPLUS_INCLUDE_PATH env variable. We have to also include LLVM’s normal include path because this is where it should search first.

#Adjust your llvm and CLT include paths to match your setup
export CPLUS_INCLUDE_PATH=/usr/local/opt/llvm/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include

This should fix any fatal error: minimum_ellipsoid/khach.h file not found errors. We might still run into linker errors like ld: library not found for -lxxx The linker also needs to be told to look for libraries in the CommandLineTools/Xcode paths by setting the LIBRARY_PATH env variable.

export LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib

Make sure to add these export statements to the .bash_rc, .zshrc, .bash_profile, or whatever shell you use, to make these adjusted environment variables available in all terminals.

rsjian commented 1 year ago

I found the issue. See: https://github.com/GeomScale/volesti/blob/ac68063c9d8616d2b964fdec803a9c5b147e3fa6/R-proj/src/Makevars#L1 https://github.com/GeomScale/volesti/blob/ac68063c9d8616d2b964fdec803a9c5b147e3fa6/include/convex_bodies/vpolytope.h#L20 The include flag -I../../external/minimum_ellipsoid which should be -I../../external. There also needs to be an additional change from https://github.com/GeomScale/volesti/blob/9fe4692ba7d9a274d939439641431e692228e65b/include/preprocess/min_sampling_covering_ellipsoid_rounding.hpp#L14 to #include "minimum_ellipsoid/khach.h"

I then ran into another issue where colamd.h was being found in /usr/local/include instead of src/external/lpsolve/headers/include so I rewrote the following two lines https://github.com/GeomScale/volesti/blob/ac68063c9d8616d2b964fdec803a9c5b147e3fa6/cran_gen/Makefile#L1-L2

as

LP_SOLVE_CPPFLAGS=-I../../headers/include \
                  $(CPPFLAGS) \
                  -I$(R_INCLUDE_DIR) \

Afterwards I followed the following steps to install the package

  1. running in R console install.packages(c('rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'testthat', 'downloader', 'xfun')) followed by setwd("/Users/rjian/volesti/cran_gen")
  2. running genCRANpkg.R
  3. running in R console setwd("/Users/rjian/volesti/cran_gen/cran_package") followed by devtools::install()

The context for running these steps instead of the instructions in the docs

Rscript -e 'Rcpp::compileAttributes()'
    R CMD INSTALL --no-multiarch --with-keep.source .

is that https://github.com/GeomScale/volesti/blob/ac68063c9d8616d2b964fdec803a9c5b147e3fa6/R-proj/src/Makevars#L11-L12 no longer works because of the changes in https://github.com/GeomScale/volesti/pull/183 which removed the directory Rproj_externals (containing the lp_solve source) from the repo and replaced it with a download in genCRANpkg.R

In retrospect maybe I should've just tried installing from master instead of develop, I'm not even trying to make any changes to the R interface.

vissarion commented 1 year ago

Indeed the correct way of building and running the R interface is via genCRANpkg.R and this should be updated in the docs.

NehaAr commented 1 year ago

can i also work on this issue

NehaAr commented 1 year ago

I am able to install the complete interface. I am using Rstudio version 4.22

NehaAr commented 1 year ago

@vissarion ..The interface is working fine.. I directly installed all the dependencies via RStudio. I am facing no issues in the installation.