How to update a package that has StanHeaders and rstan in its LinkingTo

Do you have a link to your package’s repository? It looks as if you followed the right procedure, but the conscious uncoupling of the devtools package presents an additional complication in practice.

Hi,

Please find below link to our repo:

Thank you!
Slawek

This is building and running for me when I clone it on Linux. In your above post,

that might be a mistake or just a typo. It should be
C:\Users\slawek\Documents\.R\Makevars

Also, what is

pkgbuild::has_build_tools(debug = TRUE)

?

Hi,

  1. Yes, it does work on Linux, but I am trying to build under Windows.
  2. Yes, C:\Users\slawek\Documents.R\Makevars is a typo, the correct one is C:\Users\slawek\Documents.R\Makevars
  3. Where did you find
    pkgbuild::has_build_tools(debug = TRUE) ?

Regards,
Slawek

Hi,
Actually, it was not typo, it is just how the correct string, with slash before dot, is displayed (or rather not displayed :-))

Regards,
Slawek

What do you mean where did I find pkgbuild::has_build_tools(debug = TRUE) ? The pkgbuild package is imported by rstan so you should have it on your Windows machine. If not, just do install.packages("pkgbuild"). Either way, what is the output of that command?

Hi,
Thank you very much for your help. I misunderstood you, I thought that you found pkgbuild::has_build_tools(debug = TRUE)
somewhere in the package files and are puzzled what it is for :-)
OK, so executing:

library(pkgbuild)
pkgbuild::has_build_tools(debug = TRUE)

Scanning R CMD config CC…
cc_path: c:/Rtools/mingw_64/bin/gcc
install_path: c:/Rtools
VERSION.txt
Rtools version 3.4.0.1964
Found compatible gcc from R CMD config CC
[1] TRUE

Regards,
Slawek

OK. That is helpful. It says it found a Rtools 3.4 . I don’t know what the problem is but Rtools 3.5 seems to work for more people than 3.4 does, although my 3.4 was working when no one else’s was. So, I would say to try uninstalling Rtools 3.4 and then take it from the top with
https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows#toolchain

Hi,
I am not sure if this is important, but executing
pkgbuild::has_build_tools(debug = TRUE)
without calling before
library(pkgbuild)
causes a bit different result:

Scanning R CMD config CC…
cc_path: C:Rtoolsmingw_64bingcc
‘C:Rtoolsmingw_64bingcc.exe’ does not exist
Scanning path…
ls: c:\Rtools\bin\ls.exe
gcc_path: C:\Rtools\mingw_64\bin\gcc.exe
VERSION.txt
Rtools version 3.4.0.1964
Version: 3.4
Found compatible gcc on path

Regards,
Slawek

OK. That is weird, but I would still try with Rtools 3.5.

OK, thanks, I will try.

Slawek

HI,
I tried: installed Rtools35 into c:\rtools, then followed
https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows#toolchain,
reinstalled for good measure pkgbuild:

pkgbuild::has_build_tools(debug = TRUE)
Scanning R CMD config CC…
cc_path: C:\Rtools\mingw_64\bin\gcc
install_path: C:/Rtools
VERSION.txt
Rtools version 3.5.0.4
Found compatible gcc from R CMD config CC
[1] TRUE

But I have failure at the next step:

fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ’

  • return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
  • ’ )
    sh: C:Rtoolsmingw_64bing++: command not found
    make: *** [C:/R/R-34~1.4/etc/x64/Makeconf:215: file49681234cb2.o] Error 127
    Warning message:
    running command ‘make -f “C:/R/R-34~1.4/etc/x64/Makeconf” -f “C:/R/R-34~1.4/share/make/winshlib.mk” -f “C:\Users\slawek\Documents.R\Makevars” SHLIB_LDFLAGS=’(SHLIB_CXXLDFLAGS)' SHLIB_LD='(SHLIB_CXXLD)’ SHLIB=“file49681234cb2.dll” WIN=64 TCLBIN=64 OBJECTS=“file49681234cb2.o”’ had status 2

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file49681234cb2( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file49681234cb2( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! sh: C:Rtoolsmingw_64bing++: command not found
make: *** [C:/R/R-34~1.4/etc/x64/Makeconf:215: file49681234cb2.o] Error 127
Warning message:
running command ‘make -f “C:/R/R-34~1.4/etc/x64/Makeconf” -f “C:/R/R-34~1.4/share/make/winshlib.mk” -f “C:\Users\slawek\Documents.R\Makevars” SHLIB_LDFLAGS=’(SHLIB_CXXLDFLAGS)' SHLIB_LD='(SHLIB_CXXLD)’ SHLIB=“file49681234cb2.dll” WIN=64 TCLBIN=64 OBJECTS=“file49681234cb2.o”’ had status 2
In addition: Warning message:
running command ‘C:/R/R-3.4.4/bin/x64/R CMD SHLIB file49681234cb2.cpp 2> file49681234cb2.cpp.err.txt’ had status 1

There are missing separators in the invocation to g++.

Regards,
Slawek

What does your ~/.R/Makevars file have in it now?

Hi,
Same as before, I did not change it:
CXX14FLAGS=-O3 -Wno-unused-variable -Wno-unused-function
CXX14 = $(BINPREF)g++ -m$(WIN) -std=c++1y
CXX11FLAGS=-O3 -Wno-unused-variable -Wno-unused-function

Regards,
Slawek

And what is Sys.getenv("BINPREF")?

Hi,

Sys.getenv(“BINPREF”)
[1] “C:\\Rtools\\mingw_64\\bin\\”

At the operating sys level, there are single slashes.

Regards,
Slawek

I don’t suppose building a Stan program works now, does it?

Aha! I think I have found the problem. If your Rtools is in C:\Rtools, then there should be no setting of BINPREF in .Rprofile.

Hi,
Interesting. I found another, probably related solution: use Unix style path separators in BINPREF environment variable. I do not have, or alternatively never modified, .Rprofile.

Thanks for your help,
Slawek

@Slawek_Smyl just wanted to thank you with one of the solutions you found for the “CRtoolsming_64bing++” error where the separators are missing. Like you I did not have BINPREF in the .Rprofile variable.
Your solution to use Unix style separators in BINPREF environment variable made all the difference when I was testing “rstan” in Anaconda3, RStudio1.1.456, R-3.6.1 (native to RStudio).

Since the “double back slash” style worked on my Cran R installation, I never suspected this could be a factor. Thank you @Slawek_Smyl

@bgoodri now my testing with getting “rstan” working separately with Cran R and Anaconda3-RStudio is complete and I will share specific details in a post so others may lose less hair and sleep. Thank you again for the time you take to share and engage with users here on this forum.

Sree

1 Like