Version of library in binary builds

When I run the binary build of Julia-1.2.0 or Julia-1.3.0 under a clean install of Ubuntu-19.10 I encounter problems with the version of libstdc++ in the binary build. This comes about when using RCall and loading R packages with binary dependencies built on this computer, say ggplot2. In general this occurs with any R package that depends upon the Rcpp package in R.

The error message is like

ERROR: REvalError: Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so':
  /home/bates/src/julia-1.3.0/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so)

This comes about because the installation of the Rcpp package calls the local version of g++ which links against /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28. It looks as if the version of libstdc++.so.6 shipped with the Julia binary builds is an earlier version. It defines GLIBCXX_3.4.24 but not 25 and 26.

I can probably finesse the issue by, say, a symbolic link to the system libstdc++.so.6 from the Julia lib/julia/ directory but I don’t want to mess with the binary builds unless absolutely necessary.

Can anyone suggest an alternative way around this?

Try setting

ENV["LD_LIBRARY_PATH"] = "/usr/lib/x86_64-linux-gnu"

Hopefully this should give priority to the libraries in this directory.

If it fails, set also

ENV["LD_DEBUG"] = "all"

to follow which library is being opened first.

Setting the environment variable LD_LIBRARY_PATH explicitly doesn’t work for me, unfortunately

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> ENV["LD_LIBRARY_PATH"] = "/usr/lib/x86_64-linux-gnu/"
"/usr/lib/x86_64-linux-gnu/"

julia> using RCall

julia> sleep = rcopy(R"lme4::sleepstudy")
ERROR: REvalError: Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so':
  /home/bates/src/julia-1.3.0/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so)

julia> 
bates@douglas-EliteDesk:~$ export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/"
bates@douglas-EliteDesk:~$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> ENV["LD_LIBRARY_PATH"]
"/usr/lib/x86_64-linux-gnu/"

julia> using RCall

julia> sleep = rcopy(R"lme4::sleepstudy")
ERROR: REvalError: Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so':
  /home/bates/src/julia-1.3.0/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so)

If I set ENV["LD_DEBUG"] = "all" I get a lot of information from using RCall but most of that is related to GLIBC. If I recall correctly the R process itself doesn’t have an C++ code, it is only code in R packages that uses C++. Thus the libstdc++ search only happens when after the R process has been started.

I also tried to make the Rcpp package access the libstdc++.so file shipped with the Julia package by removing the R packages and re-installing them after setting LD_LIBRARY_PATH to put the Julia libs directory first. That also failed.

You might get more effect with the LD_PRELOAD environment variable.

Did you mean this?

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> ENV["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
"/usr/lib/x86_64-linux-gnu/libstdc++.so.6"

julia> using RCall

julia> R"library(Rcpp)"
ERROR: REvalError: Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so':
  /home/bates/src/julia-1.3.0/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/bates/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so)

Thank you. It does work if I do things this way

bates@douglas-EliteDesk:~$ export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
bates@douglas-EliteDesk:~$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using RCall

julia> R"library(Rcpp)"
RObject{StrSxp}
[1] "Rcpp"      "stats"     "graphics"  "grDevices" "utils"     "datasets" 
[7] "methods"   "base"     

Yes, it’s critical that “LD_PRELOAD” is set before starting Julia so the preloading can be done before Julia gets a chance to load its own version of the library.