Invalid ELF Header

1,004 views
Skip to first unread message

Jack Olney

unread,
Aug 22, 2013, 4:27:33 AM8/22/13
to shiny-...@googlegroups.com
Hi,

I'm still fairly new to shiny and still getting to grips with it.

The issue I'm having is regarding compiled C++ code. I have a model, written in C++, that I compiled on my Mac. Everything works perfectly locally but not so well on the Rstudio Server. On my Mac, I dynamically load the compiled model (.so file) and then pass arguments to it using .Call. The model then returns an array and I have some code that creates some outputs.

The issue appears to be with dyn.load() on the server side. I get the error message "invalid ELF header". I have read that this error can mean that the compiled file is missing but this doesn't seem to be the case. My other thought was that the code is not compiled correctly to run on the server? Ideally I would be able to compile the code on the server but given the Rstudio interface this seems difficult? I was just wondering if there is an easy solution to this?

Any help would be greatly appreciated.

Many thanks,
Jack

Joe Cheng

unread,
Aug 23, 2013, 4:53:26 AM8/23/13
to shiny-...@googlegroups.com
Yes, you must compile the code on the server (or a very similar environment, i.e. the same Linux distribution/version). You could use Tools | Shell from within RStudio Server to drop to something (badly) approximating a shell prompt, and manually call make/g++/whatever from there.

The better long-term solution though, is to put your C++ code (and the rest of your analysis?) in a package, with or without Rcpp. Not only is R well designed to compile and/or distribute native code this way, but RStudio will do the compilation and installation for you when you do "Build and Reload" on the Build pane (only available if your current project is an R package).

Here's Hadley's take on the Rcpp way of doing things (in particular, note "Using Rcpp in a Package"):



--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages