Compilation problem on Windows 10 (No rule to make target 'nvector/serial/nvector_serial.o', needed by 'StanHeaders.dll')

When trying to compile StanHeaders from source I get the following error message:

make: *** No rule to make target ‘nvector/serial/nvector_serial.o’, needed by ‘StanHeaders.dll’. Stop.
ERROR: compilation failed for package ‘StanHeaders’

This happens regardless if I use the one of the last stan/math releases or the development version.

A few weeks ago I could install StanHeaders from github on other windows machines without problem. On the current machine I have installed Rtools 3.5

Does anybody have an idea what the problem could be?

System info:

  • Operating System: Windows 10
  • RStan Version: 2.2.0
  • Makevars:

CXX14FLAGS=-O3 -Wno-unused-variable -Wno-unused-function
CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y
CXX11FLAGS=-O3 -Wno-unused-variable -Wno-unused-function

CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native

  • .Rprofile:

Sys.setenv(PATH = paste(“C:/Rtools/bin”, Sys.getenv(“PATH”), sep=";"))
Sys.setenv(BINPREF = “C:/Rtools/mingw_$(WIN)/bin/”)

  • Output of devtools::session_info("rstan")

-Session info ------------------------------------------------------------------------------------------------------------------
setting value
version R version 3.6.0 (2019-04-26)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate Norwegian Bokmål_Norway.1252
ctype Norwegian Bokmål_Norway.1252
tz Europe/Berlin
date 2019-08-08

-Packages ----------------------------------------------------------------------------------------------------------------------
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
BH 1.69.0-1 2019-01-07 [1] CRAN (R 3.6.0)
callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.1)
checkmate 1.9.4 2019-07-04 [1] CRAN (R 3.6.1)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.1)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)
digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.1)
ellipsis 0.2.0.1 2019-07-02 [1] CRAN (R 3.6.1)
fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.1)
ggplot2 3.2.0 2019-06-16 [1] CRAN (R 3.6.0)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.6.1)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.1)
inline 0.3.15 2018-05-18 [1] CRAN (R 3.6.1)
labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0)
lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.1)
loo 2.1.0 2019-03-13 [1] CRAN (R 3.6.1)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
MASS 7.3-51.4 2019-03-31 [1] CRAN (R 3.6.0)
Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.0)
matrixStats 0.54.0 2018-07-23 [1] CRAN (R 3.6.1)
mgcv 1.8-28 2019-03-21 [1] CRAN (R 3.6.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.1)
nlme 3.1-139 2019-04-09 [1] CRAN (R 3.6.0)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
pkgbuild 1.0.4 2019-08-05 [1] CRAN (R 3.6.0)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.1)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.1)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.1)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.1)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.1)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.6.0)
Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1)
RcppEigen 0.3.3.5.0 2018-11-24 [1] CRAN (R 3.6.1)
reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.6.1)
rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.1)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)
rstan 2.19.2 2019-07-09 [1] CRAN (R 3.6.1)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.1)
StanHeaders 2.18.1-10 2019-06-14 [1] CRAN (R 3.6.1)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.1)
utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.1)
vctrs 0.2.0 2019-07-05 [1] CRAN (R 3.6.1)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1)
zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.1)

It is probably the subrepos. Are you using


?

I used this, but I also tried other math repos (release/v2.20.0, release/v2.19.0 release/v2.18.0) , which also didn’t work.

PS:

I am doing this because I want to be sure to get a version without this bug:

But I can’t figure out if this fix:

Is in StanHeaders on CRAN.

(In fact, I have a hard time finding the bug fix mentioned in any release notes, I just assume that it should be in stan-math/relase/v2.20.0, because this was relaesed after the big fix was merged.)

1 Like

That would be in 2.20, but for something like that you can just download the new header file with

ROOT <- "https://github.com/stan-dev/math/blob/"
HASH <- "9f0e45d43d4a653fadb23b4fc27dfc4729fab2dd/"
PATH <- "stan/math/prim/mat/prob/ordered_logistic_lpmf.hpp"
destfile <- system.file("include", "stan", "math", "prim", "mat", "prob", 
                        "ordered_logistic_lpmf.hpp", package = "StanHeaders")
download.file(url = paste0(ROOT, HASH, PATH), destfile = destfile)

Thanks for the quicker way to update a spcific function!

Unfortunately even the unchanged rstan/StanHeaders can’t compile a model (I tried 8 Schools for starters.)

Does the error message below tell you anything?

Error message:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/detail/int_float_pair.hpp:26,
from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/exponential_distribution.hpp:27,
from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/gamma_distribution.hpp:25,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat.hpp:292,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math.hpp:4,
from C:/Program Files/R/R-3.6.0/library/StanHeaders
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB filecc4690175f.cpp 2> filecc4690175f.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

Makevar file:

CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native

.Rprofile file:

Sys.setenv(PATH = paste(“C:/Rtools/bin”, Sys.getenv(“PATH”), sep=";"))
Sys.setenv(BINPREF = “C:/Rtools/mingw_$(WIN)/bin/”)

Session info:

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=Norwegian Bokmål_Norway.1252 LC_CTYPE=Norwegian Bokmål_Norway.1252 LC_MONETARY=Norwegian Bokmål_Norway.1252
[4] LC_NUMERIC=C LC_TIME=Norwegian Bokmål_Norway.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rstan_2.19.2 ggplot2_3.2.0 StanHeaders_2.18.1-10

loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 rstudioapi_0.10 magrittr_1.5 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.4-1
[7] R6_2.4.0 rlang_0.4.0 dplyr_0.8.3 tools_3.6.0 parallel_3.6.0 pkgbuild_1.0.4
[13] grid_3.6.0 gtable_0.3.0 loo_2.1.0 cli_1.1.0 withr_2.1.2 matrixStats_0.54.0
[19] lazyeval_0.2.2 assertthat_0.2.1 tibble_2.1.3 crayon_1.3.4 processx_3.4.1 gridExtra_2.3
[25] purrr_0.3.2 callr_3.3.1 ps_1.3.0 inline_0.3.15 glue_1.3.1 compiler_3.6.0
[31] pillar_1.4.2 scales_1.0.0 prettyunits_1.0.2 stats4_3.6.0 pkgconfig_2.0.2

We need verbose = TRUE to see the actual error message (which starts with error:)

I am attaching the output log.txt (57.1 KB) I get when trying to compiel the 8 schools model mit verbose = T.

Two things caught my eyes:

There was is an error/ a warning about integer_log2.hpp being depreceated …

C:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB file1b246b068fd.cpp 2> file1b246b068fd.cpp.err.txt
In file included from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/detail/int_float_pair.hpp:26,
from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/exponential_distribution.hpp:27,
from C:/Program Files/R/R-3.6.0/library/BH/include/boost/random/gamma_distribution.hpp:25,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat.hpp:292,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/stan/math.hpp:4,
from C:/Program Files/R/R-3.6.0/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file1b246b068fd.cpp:8:
C:/Program Files/R/R-3.6.0/library/BH/include/boost/pending/integer_log2.hpp:7:89: note: #pragma message: This header is deprecated. Use <boost/integer/integer_log2.hpp> instead.
BOOST_HEADER_DEPRECATED("<boost/integer/integer_log2.hpp>");

There are these error messages, which I can however not interepret:

C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s: Assembler messages:
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:6927: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:6929: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:17171: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:83280: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:83282: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:83284: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:111266: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:161656: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:162130: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200167: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200169: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200171: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200173: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200175: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200177: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200179: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200181: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:200183: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205802: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205804: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205806: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205808: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205810: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205812: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205814: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205816: Error: invalid register for .seh_savexmm
C:\Users\gubi\AppData\Local\Temp\ccBj1Gtv.s:205818: Error: invalid register for .seh_savexmm
make: *** [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file1b246b068fd.o] Error 1

You have the Error: invalid register for .seh_savexmm. Some other people have reported this problem recently on Discourse, but I don’t know if there is a conclusive resolution. I would start by removing the -march=native -mtune=native or replacing them with whatever is accurate or conservative for your processor.
`.

Thanks, the “culprit” was the flag -march=native

So on my machine with an Intel Xeon Gold 6134 @ 3.2 GHz CPU, Windows 10, and Rtools 3.50

This makevars configuration works:

CXX14FLAGS=-O3 -mtune=native
CXX11FLAGS=-O3 -mtune=native