3

I've installed Octave in Linux machine (Ubuntu 20.04) using this code:

sudo apt-add-repository -y ppa:octave/stable; 
sudo apt install -y software-properties-common; 
sudo apt-get update; 
sudo apt-get install -y octave liboctave-dev

The program works perfectly using his interface.

I now wanted to use it through R via the library RcppOctave but I'm not even able to install it.

Using the default installation doesn't work because of the R version:

> install.packages('RcppOctave')
Installing package into ‘/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘RcppOctave’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
> install.packages("RcppOctave", repos="http://R-Forge.R-project.org")
Installing package into ‘/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘RcppOctave’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

Then I tried to installed it from github (install_github('https://github.com/renozao/RcppOctave')) or directly from the tar.gz latest release, but this is the error I get:

> file <- '../../05_Software/R/RcppOctave_0.8.5.tar.gz'
> install.packages(pkgs=file, type="source", repos=NULL)
Installing package into ‘/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘RcppOctave’ ...
** package ‘RcppOctave’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
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 accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether R is a shared library... yes
Using R LDFLAGS: -Wl,--export-dynamic -fopenmp -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -lrt -ldl -lm -licuuc -licui18n
Using R CPPFLAGS: -I/usr/share/R/include
checking for octave-config... /usr/bin/octave-config
checking for mkoctfile... /usr/bin/mkoctfile
checking Octave include directory... /usr/include/octave-5.2.0/octave
checking Octave library directory... /usr/lib/x86_64-linux-gnu/octave/5.2.0
checking Octave version... 5.2.0
checking whether to infer output names for Octave function (>= 3.4.3)... yes
configure: creating ./config.status
config.status: creating src/Makevars
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/modules/Makefile
** libs
cd modules;\
make; \
mkdir -p "/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-RcppOctave/00new/RcppOctave/modules"; \
echo "Moving Octave modules to '"/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-RcppOctave/00new/RcppOctave/modules"'"; \
cp -f PKG_ADD *.oct "/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-RcppOctave/00new/RcppOctave/modules";
make[1]: se entra en el directorio '/tmp/RtmpJjatgt/R.INSTALL144cc3d8bf8b1/RcppOctave/src/modules'
/usr/bin/mkoctfile -v -c -I/usr/share/R/include  Rrng.cc 
g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave  -pthread -fopenmp -g -O2 -fdebug-prefix-map=/build/octave-rvRilm/octave-5.2.0=. -fstack-protector-strong -Wformat -Werror=format-security   -I/usr/share/R/include  Rrng.cc -o Rrng.o
Rrng.cc:32:10: fatal error: octave/config.h: No existe el archivo o el directorio
   32 | #include <octave/config.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:25: Rrng.oct] Error 1
make[1]: se sale del directorio '/tmp/RtmpJjatgt/R.INSTALL144cc3d8bf8b1/RcppOctave/src/modules'
Moving Octave modules to '/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-RcppOctave/00new/RcppOctave/modules'
cp: no se puede efectuar `stat' sobre '*.oct': No existe el archivo o el directorio
make: *** [Makevars:18: OctaveModule] Error 1
ERROR: compilation failed for package ‘RcppOctave’
* removing ‘/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1/RcppOctave’
Warning in install.packages :
  installation of package ‘../../05_Software/R/RcppOctave_0.8.5.tar.gz’ had non-zero exit status

The goal es clear: How can I install this library in R 4.1 (Ubuntu machine 20.04)?


UPDATE (20/10/21)

I've used this comand as @Gorka sujested:

sudo ln -s /usr/include/octave-5.2.0/octave/octave-config.h /usr/include/octave-5.2.0/octave/config.h

...but this is the new error:

> install_github('https://github.com/renozao/RcppOctave')
Downloading GitHub repo renozao/RcppOctave@HEAD
✓  checking for file ‘/tmp/Rtmp2OpHDN/remotes23297a629ef/renozao-RcppOctave-fcf4d02/DESCRIPTION’ ...
─  preparing ‘RcppOctave’:
✓  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  installing the package to process help pages
         -----------------------------------
─  installing *source* package ‘RcppOctave’ ...
   ** using staged installation
   checking R architecture... none
   checking for R... /usr/lib/R/bin/R
   checking for Rscript... /usr/lib/R/bin/Rscript
   checking whether loading Rprofile writes to stdout... no
   checking R version... R version 4.1.1 (2021-08-10)
   checking R platform... x86_64-pc-linux-gnu
   checking R CC... gcc -std=gnu99
   checking R CFLAGS... -g -O2 -fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -pedantic -fdiagnostics-color=always
   checking R CPPFLAGS... 
   checking R CXXFLAGS... -g -O2 -fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -pedantic -fdiagnostics-color=always
   checking for gcc... /usr/bin/gcc
   checking for gcc... gcc -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 -std=gnu99 accepts -g... yes
   checking for gcc -std=gnu99 option to accept ISO C89... none needed
   checking for g++... g++
   checking whether we are using the GNU C++ compiler... yes
   checking whether g++ accepts -g... yes
   checking for g++... /usr/bin/g++
   configure: Original R_LDFLAGS: -Wl,--export-dynamic -fopenmp -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -lrt -ldl -lm -licuuc -licui18n
   configure: Original R_CPPFLAGS: -I/usr/share/R/include
   checking whether R is a shared library... yes
   checking type of Operating System... Linux
   checking whether OS is Mac OS (Darwin)... no
   configure: Using mkoctfile with R_LDFLAGS: -Wl,--export-dynamic  -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -lrt -ldl -lm -licuuc -licui18n
   configure: Using mkoctfile with R_CPPFLAGS: -I/usr/share/R/include
   checking Octave custom binary path specification... none
   configure: using Octave binary path from $PATH
   checking for octave-config... /usr/bin/octave-config
   checking for mkoctfile... /usr/bin/mkoctfile
   checking Octave Octave bin directory... /usr/bin
   checking Octave Octave libraries directory... /usr/lib/x86_64-linux-gnu/octave/5.2.0
   checking for octave... /usr/bin/octave
   checking PATH changes... none
   checking Octave module make target... all
   checking mkoctfile command... /usr/bin/mkoctfile
   checking Octave cpp flags... -Wdate-time -D_FORTIFY_SOURCE=2
   checking Octave include flags... -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave
   checking Octave -L flags... warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead
    -L/usr/lib/x86_64-linux-gnu
   checking Octave libraries... -loctinterp -loctave 
   checking Octave C compiler... gcc
   checking Octave Fortran compiler... gfortran
   checking Octave platform... x86_64-pc-linux-gnu
   checking Octave API version... api-v53
   checking Octave version... 5.2.0
   checking whether to infer output names for Octave function (>= 3.4.3)... yes
   configure: Using Octave LDFLAGS:   -L/usr/lib/x86_64-linux-gnu -loctinterp -loctave 
   configure: Using Octave CPPFLAGS: -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave -DOCT_POST_3_4_0=1
   checking RcppOctave Octave module directory... /tmp/Rtmprp7Rn4/Rinst241a34c4f6ea/00LOCK-RcppOctave/00new/RcppOctave/modules
   configure: creating ./config.status
   config.status: creating R/config-vars.R
   configure: creating ./config.status
   config.status: creating R/config-vars.R
   config.status: creating src/Makevars
   configure: creating ./config.status
   config.status: creating R/config-vars.R
   config.status: creating src/Makevars
   config.status: creating src/modules/Makefile
   ** libs
   # Making Octave module [r_arch: all]
   make[1]: se entra en el directorio '/tmp/Rtmprp7Rn4/Rbuild241a5f538b08/RcppOctave/src/modules'
   *** Building octave module: utils.oct
   /usr/bin/mkoctfile -v utils.cc
   g++ -std=gnu++11 -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave  -pthread -fopenmp -g -O2 -fdebug-prefix-map=/build/octave-rvRilm/octave-5.2.0=. -fstack-protector-strong -Wformat -Werror=format-security    utils.cc -o /tmp/oct-XxPJKC.o
   g++ -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave  -pthread -fopenmp -g -O2 -fdebug-prefix-map=/build/octave-rvRilm/octave-5.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -shared -Wl,-Bsymbolic -Wl,-Bsymbolic-functions -Wl,-z,relro  -o utils.oct  /tmp/oct-XxPJKC.o    -L/usr/lib/x86_64-linux-gnu  -Wl,-Bsymbolic-functions -Wl,-z,relro 
   *** Building octave module: Rrng.oct
   /usr/bin/mkoctfile -v -I/usr/share/R/include -Wl,--export-dynamic  -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -lrt -ldl -lm -licuuc -licui18n Rrng.cc
   g++ -std=gnu++11 -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave  -pthread -fopenmp -g -O2 -fdebug-prefix-map=/build/octave-rvRilm/octave-5.2.0=. -fstack-protector-strong -Wformat -Werror=format-security   -I/usr/share/R/include  Rrng.cc -o /tmp/oct-zr4Boo.o
   Rrng.cc: In function ‘octave_value_list Frand(const octave_value_list&, int)’:
   Rrng.cc:163:54: warning: ‘bool octave_value::is_empty() const’ is deprecated: [4.4]: use 'isempty' instead [-Wdeprecated-declarations]
     163 |   k = ( nargs > iarg_col && !args(iarg_col).is_empty() ? long(args(iarg_col).double_value()) : n);\
         |                                                      ^
   Rrng.cc:181:1: note: in expansion of macro ‘RAND_ARGS’
     181 | RAND_ARGS(octave_fun, 0, 2, 0, 1) \
         | ^~~~~~~~~
   Rrng.cc:196:3: note: in expansion of macro ‘RAND_FUNCTION’
     196 |   RAND_FUNCTION(unif_rand, "rand")
         |   ^~~~~~~~~~~~~
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-fcn.h:33,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-builtin.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-int.h:30,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-dld.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/oct.h:32,
                    from Rrng.cc:33:
   /usr/include/octave-5.2.0/octave/../octave/ov.h:534:8: note: declared here
     534 |   bool is_empty (void) const
         |        ^~~~~~~~
   Rrng.cc: In function ‘octave_value_list Frandn(const octave_value_list&, int)’:
   Rrng.cc:163:54: warning: ‘bool octave_value::is_empty() const’ is deprecated: [4.4]: use 'isempty' instead [-Wdeprecated-declarations]
     163 |   k = ( nargs > iarg_col && !args(iarg_col).is_empty() ? long(args(iarg_col).double_value()) : n);\
         |                                                      ^
   Rrng.cc:181:1: note: in expansion of macro ‘RAND_ARGS’
     181 | RAND_ARGS(octave_fun, 0, 2, 0, 1) \
         | ^~~~~~~~~
   Rrng.cc:207:2: note: in expansion of macro ‘RAND_FUNCTION’
     207 |  RAND_FUNCTION(norm_rand, "randn")
         |  ^~~~~~~~~~~~~
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-fcn.h:33,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-builtin.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-int.h:30,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-dld.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/oct.h:32,
                    from Rrng.cc:33:
   /usr/include/octave-5.2.0/octave/../octave/ov.h:534:8: note: declared here
     534 |   bool is_empty (void) const
         |        ^~~~~~~~
   Rrng.cc: In function ‘octave_value_list Frande(const octave_value_list&, int)’:
   Rrng.cc:163:54: warning: ‘bool octave_value::is_empty() const’ is deprecated: [4.4]: use 'isempty' instead [-Wdeprecated-declarations]
     163 |   k = ( nargs > iarg_col && !args(iarg_col).is_empty() ? long(args(iarg_col).double_value()) : n);\
         |                                                      ^
   Rrng.cc:181:1: note: in expansion of macro ‘RAND_ARGS’
     181 | RAND_ARGS(octave_fun, 0, 2, 0, 1) \
         | ^~~~~~~~~
   Rrng.cc:218:2: note: in expansion of macro ‘RAND_FUNCTION’
     218 |  RAND_FUNCTION(exp_rand, "rande")
         |  ^~~~~~~~~~~~~
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-fcn.h:33,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-builtin.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-int.h:30,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-dld.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/oct.h:32,
                    from Rrng.cc:33:
   /usr/include/octave-5.2.0/octave/../octave/ov.h:534:8: note: declared here
     534 |   bool is_empty (void) const
         |        ^~~~~~~~
   Rrng.cc: In function ‘octave_value_list Frandg(const octave_value_list&, int)’:
   Rrng.cc:163:54: warning: ‘bool octave_value::is_empty() const’ is deprecated: [4.4]: use 'isempty' instead [-Wdeprecated-declarations]
     163 |   k = ( nargs > iarg_col && !args(iarg_col).is_empty() ? long(args(iarg_col).double_value()) : n);\
         |                                                      ^
   Rrng.cc:232:3: note: in expansion of macro ‘RAND_ARGS’
     232 |   RAND_ARGS("randg", 1, 4, 1, 2)
         |   ^~~~~~~~~
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-fcn.h:33,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-builtin.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-int.h:30,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-dld.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/oct.h:32,
                    from Rrng.cc:33:
   /usr/include/octave-5.2.0/octave/../octave/ov.h:534:8: note: declared here
     534 |   bool is_empty (void) const
         |        ^~~~~~~~
   Rrng.cc:238:48: warning: ‘bool octave_value::is_empty() const’ is deprecated: [4.4]: use 'isempty' instead [-Wdeprecated-declarations]
     238 |   double scale(nArgs >= 4 && !args(3).is_empty() ? args(3).double_value() : 1);
         |                                                ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-fcn.h:33,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-builtin.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-int.h:30,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-dld.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/oct.h:32,
                    from Rrng.cc:33:
   /usr/include/octave-5.2.0/octave/../octave/ov.h:534:8: note: declared here
     534 |   bool is_empty (void) const
         |        ^~~~~~~~
   Rrng.cc: In function ‘octave_value_list Frandp(const octave_value_list&, int)’:
   Rrng.cc:163:54: warning: ‘bool octave_value::is_empty() const’ is deprecated: [4.4]: use 'isempty' instead [-Wdeprecated-declarations]
     163 |   k = ( nargs > iarg_col && !args(iarg_col).is_empty() ? long(args(iarg_col).double_value()) : n);\
         |                                                      ^
   Rrng.cc:256:3: note: in expansion of macro ‘RAND_ARGS’
     256 |   RAND_ARGS("randp", 2, 3, 1, 2)
         |   ^~~~~~~~~
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-fcn.h:33,
                    from /usr/include/octave-5.2.0/octave/../octave/ov-builtin.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-int.h:30,
                    from /usr/include/octave-5.2.0/octave/../octave/defun-dld.h:32,
                    from /usr/include/octave-5.2.0/octave/../octave/oct.h:32,
                    from Rrng.cc:33:
   /usr/include/octave-5.2.0/octave/../octave/ov.h:534:8: note: declared here
     534 |   bool is_empty (void) const
         |        ^~~~~~~~
   g++ -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave  -pthread -fopenmp -g -O2 -fdebug-prefix-map=/build/octave-rvRilm/octave-5.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -shared -Wl,-Bsymbolic -Wl,-Bsymbolic-functions -Wl,-z,relro  -o Rrng.oct  /tmp/oct-zr4Boo.o   -Wl,--export-dynamic -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -lrt -ldl -lm -licuuc -licui18n  -L/usr/lib/x86_64-linux-gnu  -Wl,-Bsymbolic-functions -Wl,-z,relro 
   make[1]: se sale del directorio '/tmp/Rtmprp7Rn4/Rbuild241a5f538b08/RcppOctave/src/modules'
   # Copying Octave modules to directory '/tmp/Rtmprp7Rn4/Rinst241a34c4f6ea/00LOCK-RcppOctave/00new/RcppOctave/modules'
   g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG `"/usr/lib/R/bin/Rscript" -e "Rcpp:::CxxFlags()"` -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/octave-5.2.0/octave/.. -I/usr/include/octave-5.2.0/octave -DOCT_POST_3_4_0=1  -I'/home/cesarkero/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -Wall -pedantic -fdiagnostics-color=always -c conversion.cpp -o conversion.o
   In file included from /usr/include/octave-5.2.0/octave/../octave/lo-utils.h:35
                    from /usr/include/octave-5.2.0/octave/../octave/Array.h:41
                    from /usr/include/octave-5.2.0/octave/../octave/str-vec.h:32
                    from /usr/include/octave-5.2.0/octave/../octave/ovl.h:33
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/quit.h:178:2:warning: tra ‘;-Wpedantic
     178 | };
         |  ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/boolMatrix.h:30
                    from /usr/include/octave-5.2.0/octave/../octave/mx-base.h:34
                    from /usr/include/octave-5.2.0/octave/../octave/ov.h:40
                    from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/boolNDArray.h:121:46:warning: tra ‘;-Wpedantic
     121 | BSXFUN_OP_DECL (and, boolNDArray, OCTAVE_API);
         |                                              ^
   /usr/include/octave-5.2.0/octave/../octave/boolNDArray.h:122:45:warning: tra ‘;-Wpedantic
     122 | BSXFUN_OP_DECL (or, boolNDArray, OCTAVE_API);
         |                                             ^
   conversion.cpp:n function ‘SEXPREC* wrap(const Cell&, bool)
   conversion.cpp:134:9:error: const class Cellhas no member named ‘is_cellstr did you mean ‘iscellstr
     134 |  if(  x.is_cellstr
         |         ^~~~~~~~~~
         |         iscellstr
   conversion.cpp:n function ‘SEXPREC* Rcpp::wrap(const T&) [with T = octave_value; SEXP = SEXPREC*]
   conversion.cpp:180:24:warning: bool octave_value::is_null_value() constdeprecated: [4.4]: use 'isnull' instead [-Wdeprecated-declarations
     180 |  if( val.is_null_value()
         |                        ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:633:8:note: red here
     633 |   bool is_null_valued) const
         |        ^~~~~~~~~~~~~
   conversion.cpp:214:30:warning: bool octave_value::is_bool_type() constdeprecated: [4.4]: use 'islogical' instead [-Wdeprecated-declarations
     214 |   else if ( val.is_bool_type()
         |                              ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:701:8:note: red here
     701 |   bool is_bool_typed) const
         |        ^~~~~~~~~~~~
   conversion.cpp:219:102:warning: bool octave_value::is_integer_type() constdeprecated: [4.4]: use 'isinteger' instead [-Wdeprecated-declarations
     219 |   }else if( val.is_int32_type() || val.is_int64_type() || val.is_int16_type() || val.is_integer_type()
         |                                                                                                      ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:692:8:note: red here
     692 |   bool is_integer_typed) const
         |        ^~~~~~~~~~~~~~~
   conversion.cpp:223:30:warning: bool octave_value::is_real_type() constdeprecated: [4.4]: use 'isreal' instead [-Wdeprecated-declarations
     223 |   }else if( val.is_real_type()
         |                              ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:708:8:note: red here
     708 |   bool is_real_typed) const
         |        ^~~~~~~~~~~~
   conversion.cpp:250:33:warning: bool octave_value::is_integer_type() constdeprecated: [4.4]: use 'isinteger' instead [-Wdeprecated-declarations
     250 |   else if ( val.is_integer_type()
         |                                 ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:692:8:note: red here
     692 |   bool is_integer_typed) const
         |        ^~~~~~~~~~~~~~~
   conversion.cpp:255:30:warning: bool octave_value::is_real_type() constdeprecated: [4.4]: use 'isreal' instead [-Wdeprecated-declarations
     255 |   }else if( val.is_real_type()
         |                              ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:708:8:note: red here
     708 |   bool is_real_typed) const
         |        ^~~~~~~~~~~~
   conversion.cpp:270:24:warning: bool octave_value::is_map() constdeprecated: [4.4]: use 'isstruct' instead [-Wdeprecated-declarations
     270 |  } else if( val.is_map()/ Maps are converted into lists
         |                        ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:594:8:note: red here
     594 |   bool is_mapd) const
         |        ^~~~~~
   conversion.cpp:307:25:warning: bool octave_value::is_cell() constdeprecated: [4.4]: use 'iscell' instead [-Wdeprecated-declarations
     307 |  } else if( val.is_cell() Cell objects are used for character vectors
         |                         ^
   In file included from /usr/include/octave-5.2.0/octave/../octave/ovl.h:36
                    from rcpp_octave.h:32
                    from conversion.cpp:5
   /usr/include/octave-5.2.0/octave/../octave/ov.h:541:8:note: red here
     541 |   bool is_celld) const
         |        ^~~~~~~
   conversion.cpp:n function ‘T Rcpp::as(SEXP) [with T = octave_value; SEXP = SEXPREC*]
   conversion.cpp:471:50:error: valid initialization of reference of type ‘const octave_value&from expression of type ‘octave_value_list
     471 |    const octave_value& ol = as<octave_value_list>(x)
         |                             ~~~~~~~~~~~~~~~~~~~~~^~~
   make: *** [/usr/lib/R/etc/Makeconf:177: conversion.o] Error 1
   ERROR: compilation failed for package ‘RcppOctave’
─  removing ‘/tmp/Rtmprp7Rn4/Rinst241a34c4f6ea/RcppOctave’
         -----------------------------------
   ERROR: package installation failed
Error: Failed to install 'RcppOctave' from GitHub:
  System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E>       |        ^~~~~~~
E> conversion.cpp:n function ‘T Rcpp::as(SEXP) [with T = octave_value; SEXP = SEXPREC*]
E> conversion.cpp:471:50:error: valid initialization of reference of type ‘const octave_value&from expression of type ‘octave_value_list
E>   471 |    const octave_value& ol = as<octave_value_list>(x)
E>       |                             ~~~~~~~~~~~~~~~~~~~~~^~~
E> make: *** [/usr/lib/R/etc/Makeconf:177: conversion.o] Error 1
E> ERROR: compilation failed for package ‘RcppOctave’
E> * removing ‘/tmp/Rtmprp7Rn4/Rinst241a34c4f6ea/RcppOctave’
E>       -----------------------------------
E> ERROR: package installation failed
Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
  • 2
    The package has been [off CRAN since 2017](https://cloud.r-project.org/web/packages/RcppOctave/index.html) so maybe your assumption that it would 'just build' is not valid. Did you try contacting the author via an issue ticket at the GitHub repo? – Dirk Eddelbuettel Oct 12 '21 at 13:38
  • 2
    It seems that in the new versions of octave, the file `octave/config.h` has been replaced with `octave/octave-config.h`. Does `sudo ln -s /usr/include/octave-5.2.0/octave/octave-config.h /usr/include/octave-5.2.0/octave/config.h` fix the building issue? – Gorka Oct 19 '21 at 14:04
  • Thanks. It seems that the installation from github goes further but a new error appears. – César Arquero Cabral Oct 20 '21 at 09:23
  • 1
    Take a look at [swig_octave_version.h](https://github.com/renozao/RcppOctave/blob/fcf4d02d1dd3a648b0b7c3c5569ae96c9bf78400/src/swig_octave_version.h) file. I think you need to use the Octave version [3.8](https://www.gnu.org/software/octave/news/release/2013/12/31/octave-3.8.0-released.html) or less for `RcppOctave`. – Gorka Oct 20 '21 at 10:17
  • Assuming the latest version of the package actually worked at the time it was uploaded, I would download the source of this version ( https://cran.r-project.org/src/contrib/Archive/RcppOctave/RcppOctave_0.18.1.tar.gz ). The version was published 2015-10-06. So I would download and install the Octave version that was current on this day (maybe even a little bit older - see https://wiki.octave.org/Release_History ) - So try to install either version 4.0.0 or 3.8.2 – Steffen Moritz Oct 21 '21 at 21:21
  • https://launchpad.net/ubuntu/+source/octave/3.8.2-4.1 – Steffen Moritz Oct 21 '21 at 21:26

2 Answers2

1

Sometimes just downloading and installing/building the package on your own is enough, when the package ... is not available for this version of R error message appears.

In this case obviously not ... and Gorka is probably right, when he says it could be the Octave version.

In general I would rather try to get the latest CRAN version RcppOctave_0.18.1 running instead of the GitHub version (whose latest updates were also years ago).

Since the package seems to be temporary or permanently discontinued you never know, if they stopped their Github version in the middle of some changes that didn't work out.

Whereas for the latest CRAN version it is more likely that it was a staple build, that worked at the time it was being uploaded (2015-10-06).

So probably if you replicate the environment from this time (R version, Version of package dependencies, Ubuntu version, Octave version) you have a pretty high chance to get this package running.

But just bringing the Octave version to the current version at the time of RcppOctave_0.18.1 release might also already do the job. Looking at https://wiki.octave.org/Release_History indicates that version 4.0.0 or 3.8.2 could be a good fit.

I am not really a linux/ubuntu user, but I'd guess just

apt-get install octave=4.0.0

won't do the job of installing the package, since the package must be present in the repository/ package manager. Probably you have to get the old package version from somewhere / add a repository that includes the package version (which you also did in your code with apt-add-repository -y ppa ...).

For Ubuntu you can find old packages at launchpad https://launchpad.net/ubuntu/trusty/+source/octave https://launchpad.net/ubuntu/+source/octave/3.8.2-4.1

For Debian you can find old packages at https://snapshot.debian.org/

Would be interesting to see if building the package works with Octave 4.0.0 or 3.8.2 (and if it is possible to install these).

If you get it running this way and you anyway don't need functionality from newer Octave versions - perfect.

If not ... I don't know of any other R - Octave interface package, which would probably rule out the solution of just using another R package.

A solution (depending on your plans) could be using system() / system2() for invoking system commands.

system invokes the OS command specified by command.

Since (as far as I know) you can also run Octave scripts from the shell, this could be a possible workaround.

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
  • Thanks for the answer but I would rather not use an older version of octave.Even if I know nothing about it I needed for a course and may be I would end finding other problems like functions changed, or others. Anyway I will try to install an older versions and then check if R works with it. – César Arquero Cabral Oct 25 '21 at 10:10
  • Depending on what exactly you want to do, you could try to use Octave Scripts via the shell (which you can use via R's system() - see bottom of the answer). So these scripts could still somehow part of the R workflow / be triggered by R. You would have to read in the outputs of the script. Depending on how you want to interact with the Octave code, this would mean extra effort. – Steffen Moritz Oct 26 '21 at 14:43
1

I also failed to install RcppOctave in R 4.1.2.

Instead I found a way to run Octave script in R Markdown file. Take a look at this example:

```{octave, engine.path='/usr/local/opt/octave/bin/octave', warning=F}
addpath('/Applications/freesurfer/matlab')

[vertex_coords_sp, faces] = read_surf("/Applications/freesurfer/subjects/fsaverage5/surf/lh.sphere")

save('~/RAS_coord_fs_sphere.mat','-v6')
```

You can refer to this page for more details on Octave code in R Markdown.

Hope this could help someone who also have trouble dealing with split environments :D

Yeoman
  • 51
  • 5
  • Hi @joão-dias Thank you for your edits. I would rather keep the backticks, for that's what the codes look like in RStudio GUI and [other posts here](https://stackoverflow.com/questions/13090838/r-markdown-avoiding-package-loading-messages), which might be more friendly to newbies to R Markdown. – Yeoman Dec 23 '21 at 15:07
  • Ok, understood. I thought it was a typo ;) – João Dias Dec 23 '21 at 16:40