[R] update (Re: loading compiled C++ code as shared library)

Faheem Mitha faheem at email.unc.edu
Thu Jul 25 19:57:16 CEST 2002



On Thu, 25 Jul 2002, Prof Brian D Ripley wrote:

> On Wed, 24 Jul 2002, Faheem Mitha wrote:
>
> > On Wed, 24 Jul 2002, Faheem Mitha wrote:
> >
> > >
> > > Dear People,
> > >
> > > Over the last few days I've been writing C++ to compile as a shared
> > > library (previously I have always used C). Not entirely to my surprise, I
> > > am getting errors. Specifically, when I try to load the shared library, I
> > > get
> > >
> > > Error in dyn.load(x, as.logical(local), as.logical(now)) :
> > > 	unable to load shared library
> > > "/home/faheem/research/thesis/sim/ms/ms.so":
> > >   /home/faheem/research/thesis/sim/ms/ms.so: undefined symbol:
> > > __gxx_personality_v0
> >
> > This appears to have something to do with my compile options (see below).
> > Just doing "R CMD SHLIB ms.cc -o ms.so" does not give the error. Anyone
> > have any idea what might be causing this?
>
> I suspect you are using g++-3.1 with R compiled with gcc < 3.0.

Yes, that is right. 2.95.4, which is still the standard for Debian, at
least on i386 Linux.

> You often can't mix-and-match versions of gcc across major revision
> levels, and you certainly can't use gcc 3.1 on C++ code and mix it with
> earlier versions as there is a C++ ABI change.
>
> R's configure does compatibility checks when it selects the C, C++ and
> Fortran compilers.  If you change your compilers it is a good idea to
> rebuild R (and I'm pretty sure I had to when changing from gcc 2.95.3 to
> 3.x).

Yes, I recompiled R using gcc 3.1 late yesterday, as I also suspected this
was probably the problem. This was easy using Debian, and Dirk in fact
helpfully added a note to the rules file that R compiled Ok with the gcc
3.0 compilers. In fact, it compiled Ok with the gcc 3.1 compilers too.

It took me a little time to realise this was probably the problem, since
I've not had similar problems with C code.

Once I had recompiled, the problem went away. I hope that soon gcc will
stabilise at a 3+ level (I've heard rumours that 3.2 will break
compatability with 3.1), and R can be compiled with it by default, since
g++ for gcc < 3.0 is not entirely standards compliant.

Thank you for taking the time to respond.

                                              Sincerely, Faheem Mitha.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list