[Rd] R doesn't compile on FreeBSD 10.2

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Aug 31 14:34:39 CEST 2015

First, this there is no evidence here of a 'compilation' failure: it 
seems to be about installation, and more specifically about loading 
dynamic libs.

Second, we don't have all the pertinent information such as the 
configure options used and the architecture (x86_64?).  I am going to 
have to guess none as none were mentioned, but using --enable-R-shlib 
would be pertinent.

On 31/08/2015 05:47, Davor Cubranic wrote:
> On FreeBSD 10.2, I get the following error when compiling R from the
> Subversion trunk (with "configure && make"):

You have not told us which revision.  A basic check is to see if you can 
build the latest released version, as the trunk is 'Under development'.
>      cc -shared -L/usr/local/lib -o tools.so text.o init.o Rmd5.o md5.o signals.o install.o getfmts.o http.o gramLatex.o gramRd.o
>      mkdir ../../../../library/tools/libs
>      installing 'sysdata.rda'
>      Error in dyn.load(file, DLLpath = DLLpath, ...) :
>        unable to load shared object '/usr/home/davor/R-dev/R-trunk/library/tools/libs/tools.so':
>        /usr/home/davor/R-dev/R-trunk/library/tools/libs/tools.so: Undefined symbol "R_ClassSymbol"
>      Error: unable to load R code in package 'tools'
>      Execution halted
>      *** Error code 1
>      Stop.
>      make[4]: stopped in /usr/home/davor/R-dev/R-trunk/src/library/tools
> The system is running a 64-bit FreeBSD 10.2-RELEASE-p4, with clang 3.4.1
> and gfortran 4.8.5.
> Configure log is attached.
> Davor

Here is a series of checks for that symbol (results from a working Linux 

auk% nm -g bin/exec/R  | grep R_ClassSymbol
0000000000962ec0 B R_ClassSymbol

auk% nm -g src/main/main.o | grep R_ClassSymbol
0000000000000008 C R_ClassSymbol

auk% nm -g library/tools/libs/tools.so  | grep R_ClassSymbol
                  U R_ClassSymbol

auk% nm -g src/library/tools/src/gramRd.o | grep R_ClassSymbol
                  U R_ClassSymbol

So R_ClassSymbol is unresolved in the tools package and should be 
resolved by loading into the main R executable. On Linux that is 
achieved by the linker flag


as part of MAIN_LDFLAGS in Makeconf in the top-level directory.  We have 
in configure.ac


but those were from the days when FreeBSD used gcc, and it is possible 
that your use of clang[*] requires -Wl,--export-dynamic . If so, add to 


It would also be worth trying a build with --enable-R-shlib, as that 
resolves R_ClassSymbol and similar differently.

[*] Unfortunately clang accepts many flags for gcc compatibility, but 
often silently ignores them. And it does not document fully which flags 
it actually implements.  It is not much easier with gcc: e.g. 4.9.2 
documents a flag -rdynamic with the same effect.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

More information about the R-devel mailing list