stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.04k stars 268 forks source link

Compilation ERROR #561

Open JenniferUOM opened 6 years ago

JenniferUOM commented 6 years ago

Summary:

I am starting to use Stan interface for R but have a compilation error

Description:

I installed Rtools on my C:/ drive and followed all the steps described here: https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows

Reproducible Steps:

> Sys.getenv('PATH') [1] "C:\Program Files\R\R-3.5.1\bin\x64;c:\Rtools\bin;c:\Rtools\mingw_64\bin;"

> system('g++ -v') Using built-in specs. COLLECT_GCC=c:\Rtools\mingw_64\bin\G__~1.EXE COLLECT_LTO_WRAPPER=c:/Rtools/mingw_64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.3/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-4.9.3/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/home/Jeroen/mingw-gcc-4.9.3/x86_64-493-posix-seh-rt_v3-s/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-static --disable-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --with-m... Thread model: posix gcc version 4.9.3 (x86_64-posix-seh, Built by MinGW-W64 project)

> system('where make') c:\Rtools\bin\make.exe

Current Output:

And I get this error message at the last step: *fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , ' return ScalarReal( INTEGER(x)[0] REAL(y)[0] ) ; ' )** Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lStanHeaders collect2.exe: error: ld returned 1 exit status

> fx( 2L, 5 ) Error in .Primitive(".Call")(<pointer: (nil)>, x, y) : NULL value passed as symbol address

RStan Version:

‘2.17.3’

R Version:

R version 3.5.1 (2018-07-02)

Operating System:

64 bit

bgoodri commented 6 years ago

It looks as if it cannot find the StanHeaders R package (which should have been brought in when you installed rstan).

On Tue, Sep 18, 2018 at 12:52 PM JenniferUOM notifications@github.com wrote:

Summary:

I am starting to use Stan interface for R but have a compilation error Description:

I installed Rtools on my C:/ drive and followed all the steps described here: https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows Reproducible Steps:

> Sys.getenv('PATH') [1] "C:\Program Files\R\R-3.5.1\bin\x64;c:\Rtools\bin;c:\Rtools\mingw_64\bin;"

> system('g++ -v') Using built-in specs. COLLECT_GCC=c:\Rtools\mingw_64\bin\G__~1.EXE

COLLECT_LTO_WRAPPER=c:/Rtools/mingw_64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.3/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-4.9.3/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/home/Jeroen/mingw-gcc-4.9.3/x86_64-493-posix-seh-rt_v3-s/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-static --disable-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --with-m... Thread model: posix gcc version 4.9.3 (x86_64-posix-seh, Built by MinGW-W64 project)

> system('where make') c:\Rtools\bin\make.exe Current Output:

And I get this error message at the last step:

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , ' return ScalarReal( INTEGER(x)[0] REAL(y)[0] ) ; ' )* Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lStanHeaders collect2.exe: error: ld returned 1 exit status

> fx( 2L, 5 ) Error in .Primitive(".Call")(<pointer: (nil)>, x, y) : NULL value passed as symbol address RStan Version:

‘2.17.3’ R Version:

R version 3.5.1 (2018-07-02) Operating System:

64 bit

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/561, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqgWItrvGGvojFLAEIoB8w5sSpkJ_ks5ucSS3gaJpZM4WuVxL .

JenniferUOM commented 6 years ago

Thanks for your reply. However I do have the StanHeaders R package. I re-installed Rtools and removed the 32bits toolchain, Rstan and StanHeaders packages as well. But this time the compilation error regarding StanHeaders package occurs when I try the 8 schools example (https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#how-to-use-rstan).

Output: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! file11e04aef4e5b.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory

include <stan/model/model_header.hpp>

                                   ^

compilation terminated. make: *** [file11e04aef4e5b.o] Error 1 In addition: Warning messages: 1: In readLines(file, warn = TRUE) : incomplete final line found on 'C:\Users\mbmhrjl3\Stan\examples\8schools.stan' 2: In system(cmd, intern = !verbose) : running command 'C:/PROGRA~1/R/R-35~1.1/bin/x64/R CMD SHLIB file11e04aef4e5b.cpp 2> file11e04aef4e5b.cpp.err.txt' had status 1

chisha78 commented 6 years ago

I have exactly the same errors as the last message from @JenniferUOM

Thanks for your reply. However I do have the StanHeaders R package. I re-installed Rtools and removed the 32bits toolchain, Rstan and StanHeaders packages as well. But this time the compilation error regarding StanHeaders package occurs when I try the 8 schools example (https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#how-to-use-rstan).

Output: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! file11e04aef4e5b.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory

include <stan/model/model_header.hpp>

^ compilation terminated. make: *** [file11e04aef4e5b.o] Error 1 In addition: Warning messages: 1: In readLines(file, warn = TRUE) : incomplete final line found on 'C:\Users\mbmhrjl3\Stan\examples\8schools.stan' 2: In system(cmd, intern = !verbose) : running command 'C:/PROGRA1/R/R-351.1/bin/x64/R CMD SHLIB file11e04aef4e5b.cpp 2> file11e04aef4e5b.cpp.err.txt' had status 1

@JenniferUOM did you manage to solve it?

bgoodri commented 6 years ago

Your StanHeaders (or possibly rstan) is not installed correctly if it cannot find stan/model/model_header.hpp.

JenniferUOM commented 6 years ago

As a matter of fact, the issue seemed to be due to the wrong library path. I had to make sure I had installed Rtools and R in the right directory folder (C:/ drive).

I hope it can be of any help.

Best regards Jennifer

chisha78 commented 6 years ago

Thank you so much, @JenniferUOM and @bgoodri, for your suggestions, but now I am getting a different error message I will log another comment.

bgoodri commented 6 years ago

@chisha78 Are you still getting an error after install.packages("rstan") and if so, what is it?

chisha78 commented 6 years ago

@bgoodri I have downloaded an older version of "StanHeaders" and seem to have done the trick. Thanks for checking.

Tpapanick commented 6 years ago

Hello @bgoodri I have just installed Rstan I am getting a similar error when I try to compile 8schools.stan whilst I did all the steps correctly.

Output Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core/operator_addition.hpp:7:0, from C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core.hpp:16, from C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/mat.hpp:4, from C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math.hpp:4, from C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/src/stan/model/model_header.hpp:4, from file383431595d19.cpp:8: C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/prim/scal/fun/is_nan.hpp: In function 'bool stan::math::is_nan(double)': C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/prim/scal/fun/is_nan.hpp:17:39: e In addition: Warning message: running command 'C:/PROGRA~1/R/R-3.4.4/bin/x64/R CMD SHLIB file383431595d19.cpp 2> file383431595d19.cpp.err.txt' had status 1

Any ideas?? Thanks a lot

bgoodri commented 6 years ago

C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/prim/scal/fun/is_nan.hpp: In function 'bool stan::math::is_nan(double)': C:/Users/papan/OneDrive/Documents/R/win-library/3.4/StanHeaders/include/stan/math/prim/scal/fun/is_nan.hpp:17:39: e

Is there more to the error message here? It looks like it has been cut off.

Tpapanick commented 6 years ago

No it ends: fun/is_nan.hpp:17:39: er

I forgot to copy and paste the 'r'

bgoodri commented 6 years ago

What about

file.edit(file.path(tempdir(), "file383431595d19.cpp.err.txt"))

or whatever is the name of the file after the 2> in the last line of the error message?

On Tue, Oct 23, 2018 at 9:37 AM Tpapanick notifications@github.com wrote:

No it ends: fun/is_nan.hpp:17:39: er

I forgot to copy and paste the 'r'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/561#issuecomment-432249195, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqvYs9tG6K7iuBGffk2p8wTGf3kTqks5unxuogaJpZM4WuVxL .

Tpapanick commented 6 years ago

The file is empty...

Tpapanick commented 6 years ago

What about file.edit(file.path(tempdir(), "file383431595d19.cpp.err.txt")) or whatever is the name of the file after the 2> in the last line of the error message? On Tue, Oct 23, 2018 at 9:37 AM Tpapanick @.***> wrote: No it ends: fun/is_nan.hpp:17:39: er I forgot to copy and paste the 'r' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#561 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqvYs9tG6K7iuBGffk2p8wTGf3kTqks5unxuogaJpZM4WuVxL .

Problem solved thanks a lot for you time

bgoodri commented 6 years ago

Problem solved how? A lot of people are running into a lot of issues like this with the transition from 2.17 (C++03) to 2.18 (C++14).

On Tue, Oct 23, 2018 at 12:12 PM Tpapanick notifications@github.com wrote:

What about file.edit(file.path(tempdir(), "file383431595d19.cpp.err.txt")) or whatever is the name of the file after the 2> in the last line of the error message? … <#m3885530861890971691> On Tue, Oct 23, 2018 at 9:37 AM Tpapanick @.***> wrote: No it ends: fun/is_nan.hpp:17:39: er I forgot to copy and paste the 'r' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#561 (comment) https://github.com/stan-dev/rstan/issues/561#issuecomment-432249195>, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqvYs9tG6K7iuBGffk2p8wTGf3kTqks5unxuogaJpZM4WuVxL .

Problem solved thanks a lot for you time

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/561#issuecomment-432310850, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqgz0DrdvP-8l5qe2uBQ2MgTS99_rks5unz_YgaJpZM4WuVxL .

Tpapanick commented 6 years ago

Problem solved how? A lot of people are running into a lot of issues like this with the transition from 2.17 (C++03) to 2.18 (C++14). On Tue, Oct 23, 2018 at 12:12 PM Tpapanick @.> wrote: What about file.edit(file.path(tempdir(), "file383431595d19.cpp.err.txt")) or whatever is the name of the file after the 2> in the last line of the error message? … <#m3885530861890971691> On Tue, Oct 23, 2018 at 9:37 AM Tpapanick @.> wrote: No it ends: fun/is_nan.hpp:17:39: er I forgot to copy and paste the 'r' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#561 (comment) <#561 (comment)>>, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqvYs9tG6K7iuBGffk2p8wTGf3kTqks5unxuogaJpZM4WuVxL . Problem solved thanks a lot for you time — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#561 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqgz0DrdvP-8l5qe2uBQ2MgTS99_rks5unz_YgaJpZM4WuVxL .

I'm sorry I forgot to mention it earlier. I just updated everything to the latest version. (R,Rtools,Rstudio)

Many thanks for your time and your help.

RichardIanBarnes commented 6 years ago

Hi - I previously ran into the same problem as @JenniferUOM above running on Windows 8. I think, @bgoodri, you have updated the RStan install instructions for Windows on the Wiki. I uninstalled everything (Rtools and RStan) and reinstalled following your new instructions and everything works fine now. Thank you very much @bgoodri for all your help.