Error: Cannot export ++gnu_lto_v1: symbol not defined collect2.exe: error ld returned 1 exit status

602 views
Skip to first unread message

Jesse Wolfhagen

unread,
Jul 8, 2016, 9:20:33 AM7/8/16
to Stan users mailing list
Hello,

I am trying to install rstan and am continually getting this error that prevents any C++ code (from rstan or the test code snippets) from running correctly. I can't find any straightforward venues to solve this issue outside of the rstan community, so even if you could just point me to the right place that'd be extremely helpful!

I have been following the "RStan Getting Started" guide and have consistently run into the same issue - I have reinstalled everything multiple times and keep hitting a wall here.

This is the output when I try to run the code found at https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started to "Verify that your toolchain works by executing in R":
> fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
+                    ' )
Cannot export __gnu_lto_v1: symbol not defined
collect2.exe: error: ld returned 1 exit status

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 file24f838966efd( SEXP x, SEXP y) ;
 14: }
 15: 
 16: // definition
 17: 
 18: SEXP file24f838966efd( 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! Cannot export __gnu_lto_v1: symbol not defined
collect2.exe: error: ld returned 1 exit status

The error continues if I blindly ignore reality and then try to use the Stan 8 schools data example.

rstan and all of the related packages install without issues. Their versions:
> packageVersion("rstan")
[1] ‘2.10.1’
> packageVersion("inline")
[1] ‘0.3.14’
> packageVersion("Rcpp")
[1] ‘0.12.5’

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

loaded via a namespace (and not attached):
[1] rsconnect_0.4.3 tools_3.3.1     inline_0.3.14

I am using Rtools33 (located in c:/Rtools) - the beginning of my PATH is thus:
> Sys.getenv("PATH")
[1] "C:\\R\\R-3.3.1\\bin\\x64;c:\\Rtools\\bin;c:\\Rtools\\mingw_64\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\system32\\wbem;C:\\Program Files (x86)...

My version of g++ is:
> system("g++ --version")
G__~1.EXE (x86_64-posix-seh, Built by MinGW-W64 project) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thank you! I am at an archaeological dig and so have limited windows of internet access each day - I would really appreciate any help with this!

Bob Carpenter

unread,
Jul 8, 2016, 1:03:22 PM7/8/16
to stan-...@googlegroups.com
Does that cxxfunction thing still work? I thought Daniel had
found that the diagnostics no longer worked.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ben Goodrich

unread,
Jul 8, 2016, 2:14:44 PM7/8/16
to Stan users mailing list
On Friday, July 8, 2016 at 1:03:22 PM UTC-4, Bob Carpenter wrote:
Does that cxxfunction thing still work?  I thought Daniel had
found that the diagnostics no longer worked.

It works generally, but the fortran part doesn't unless you have gfortran installed.

I don't know why it is not working in this case but I would suggest to start by taking -flto and -ffat-lto-objects out of the file that is returned by

normalizePath("~/.R/Makevars")

Ben


Jesse Wolfhagen

unread,
Jul 9, 2016, 12:11:04 PM7/9/16
to Stan users mailing list
Thank you so much, that worked perfectly! Had to eventually move R to a path without a space after getting a new error (as mentioned in another thread here), but your advice fixed my problem immediately and now rstan appears to be working.

Thanks again!

Soutik Ghosal

unread,
Sep 10, 2016, 4:59:26 PM9/10/16
to Stan users mailing list
Hi Jesse , I am having the same problem as you had, but I didn't understand the suggestion by Ben Goodrich. Can someone illustrate a bit ?

Avraham Adler

unread,
Sep 11, 2016, 1:29:45 AM9/11/16
to Stan users mailing list
The error "gnu_lto_v1" relates to link-time optimization. By removing "-flto" from Makevars you are no longer asking GCC to perform LTO, so the problem should go away. On Windows, the current gcc is 4.9.3 whose LTO is existent but not a flawless as later versions of GCC and it tends to cause R-related packages to fail.

Avi

Avraham Adler

unread,
Sep 13, 2016, 2:46:35 PM9/13/16
to Stan users mailing list
On Saturday, September 10, 2016 at 4:59:26 PM UTC-4, Soutik Ghosal wrote:Hi Jesse , I am having the same problem as you had, but I didn't understand the suggestion by Ben Goodrich. Can someone illustrate a bit ?

On Sunday, September 11, 2016 at 1:29:45 AM UTC-4, Avraham Adler wrote:
The error "gnu_lto_v1" relates to link-time optimization. By removing "-flto" from Makevars you are no longer asking GCC to perform LTO, so the problem should go away. On Windows, the current gcc is 4.9.3 whose LTO is existent but not a flawless as later versions of GCC and it tends to cause R-related packages to fail.

The other option that may work, but will void your warranty, is to go to R_HOME/etc/x64 and edit Makeconf to add "gcc-" in front of AR, NM, and RANLIB. E.g. Change AR = $(BINPREF)ar to AR = $(BINPREF)gcc-ar, and same for NM and RANLIB. In GCC 4.x, only the "gcc-" headed files have scripts that allow them to process LTO properly.

Avi
Reply all
Reply to author
Forward
0 new messages