From plummerm at iarc.fr  Wed Apr 22 19:01:48 2015
From: plummerm at iarc.fr (Martyn Plummer)
Date: Wed, 22 Apr 2015 17:01:48 +0000
Subject: [Rd] shlib problems with Intel compiler
In-Reply-To: <4DD36A5A-17CB-4AC8-9935-3C1A89CD683D@noaa.gov>
References: <9D2F27BD-240B-419F-8C0A-CCC3B1B4D680@noaa.gov>
	<1429716621.24336.53.camel@iarc.fr>,
	<4DD36A5A-17CB-4AC8-9935-3C1A89CD683D@noaa.gov>
Message-ID: <99C26525-2F66-44DB-B17B-63E5B86846B3@iarc.fr>

I was assuming that R was configured with --enable-R-shlib but if that's not the case then you don't need it.

Martyn


> On 22 Apr 2015, at 18:40, Andy Jacobson (NOAA Affiliate) <andy.jacobson at noaa.gov> wrote:
> 
> Hi Martyn,
> 
> Thanks for your insight, that seems pretty direct.  Unfortunately, I did not compile this version of R (it's on a large supercomputer system and this version of R was installed by the admins).  Using "R CMD config", I see the following relevant settings:
> 
> DYLIB_LD = icc -std=gnu99
> DYLIB_LDFLAGS = -shared -openmp
> LDFLAGS = -L/opt/compilers/intel/cce/9.1.039/lib -L/opt/compilers/intel/fce/9.1.033/lib -L/usr/local/lib64
> SHLIB_CXXLD = icpc
> SHLIB_CXXLDFLAGS = 
> SHLIB_LD = icc -std=gnu99
> SHLIB_LDFLAGS = -shared
> 
> It looks like the SHLIB_CXXLDFLAGS is missing the "-shared -lR -L<loc-of-libR>".  It's a mystery to me how R was built and configured such that it has incomplete/incorrect flags.
> 
> By trial and error I figured out how to use a .R/Makevars setting to add the required flags to SHLIB_CXXLDFLAGS.  (It sure would have been useful to have a reference about the syntax and variable names that the Makevars file can contain...is that documented somewhere?)
> 
> I wonder if the recommendation for "-lR" is correct.  None of the other packages are compiled with that flag, and everything seems to compile and load OK in R without using that.
> 
> Best Regards,
> 
> Andy
> 
>> On Apr 22, 2015, at 9:30 AM, Martyn Plummer <plummerm at iarc.fr> wrote:
>> 
>> On Tue, 2015-04-21 at 11:46 -0600, Andy Jacobson (NOAA Affiliate) wrote:
>>> Hi,
>>> 
>>> I'm encountering trouble compiling caTools_1.17.1.tar.gz and
>>> e1071_1.6-4.tar.gz on a Linux system using the Intel compiler suite.
>>> 14 other packages I generally use installed without any trouble.  I
>>> notice both of these trouble packages have a C++ component, so I
>>> wonder if that might be the issue.  Below, there's information on my
>>> platform, compiler, and some diagnostic output showing the errors.
>>> 
>>> Advice appreciated!
>>> 
>>> Thanks,
>>> 
>>> Andy
>> 
>> There are two things missing when R tries to create the shared object
>> file on this line:
>> 
>> icpc -L/usr/local/lib64 -o e1071.so Rsvm.o cmeans.o cshell.o floyd.o
>> svm.o
>> 
>> Firstly, the compiler flag "-shared" is missing. It tells the compiler
>> to build a shared object instead of an executable. Secondly the linker
>> flag "-lR" is missing, along with the "-L" flag that tells the linker
>> where to find the shared R library.
>> 
>> To find out what went wrong, you should share the configuration you used
>> when building R.
>> 
>> Martyn
>> 
>>> 
>>> 
>>> Intel compiler suite:  icc (ICC) 14.0.2 20140120
>>> 
>>> sessionInfo() reports:
>>> 
>>> R version 3.1.3 (2015-03-09)
>>> Platform: x86_64-unknown-linux-gnu (64-bit)
>>> Running under: Red Hat Enterprise Linux Server release 6.5 (Santiago)
>>> 
>>> locale:
>>> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
>>> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
>>> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
>>> [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
>>> [9] LC_ADDRESS=C               LC_TELEPHONE=C            
>>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
>>> 
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base     
>>> 
>>> loaded via a namespace (and not attached):
>>> [1] tools_3.1.3
>>> 
>>> 
>>> Abbreviated versions of the output from R CMD INSTALL:
>>> 
>>> For caTools:
>>> 
>>> * installing to library ?/scratch3/BMC/co2/lib/R-3.1/x86_64-unknown-linux-gnu?
>>> * installing *source* package ?caTools? ...
>>> ** package ?caTools? successfully unpacked and MD5 sums checked
>>> ** libs
>>> icpc -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -fp-model precise  -c Gif2R.cpp -o Gif2R.o
>>> icpc -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -fp-model precise  -c GifTools.cpp -o GifTools.o
>>> icc -std=gnu99 -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -wd188 -ip -fp-model precise  -c runfunc.c -o runfunc.o
>>> icpc -L/usr/local/lib64 -o caTools.so Gif2R.o GifTools.o runfunc.o
>>> /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
>>> (.text+0x20): undefined reference to `main'
>>> Gif2R.o: In function `imwritegif':
>>> /tmp/RtmpEfnBsm/R.INSTALL17c3a7327d4fb/caTools/src/Gif2R.cpp:19: undefined reference to `R_chk_calloc'
>>> /tmp/RtmpEfnBsm/R.INSTALL17c3a7327d4fb/caTools/src/Gif2R.cpp:23: undefined reference to `R_chk_free'
>>> ... (many more R_* undefined references)
>>> 
>>> For e1071:
>>> 
>>> * installing to library ?/scratch3/BMC/co2/lib/R-3.1/x86_64-unknown-linux-gnu?
>>> * installing *source* package ?e1071? ...
>>> ** package ?e1071? successfully unpacked and MD5 sums checked
>>> checking for C++ compiler default output file name... a.out
>>> checking whether the C++ compiler works... yes
>>> checking whether we are cross compiling... no
>>> checking for suffix of executables... 
>>> checking for suffix of object files... o
>>> checking whether we are using the GNU C++ compiler... yes
>>> checking whether icpc accepts -g... yes
>>> ** libs
>>> icc -std=gnu99 -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -wd188 -ip -fp-model precise  -c Rsvm.c -o Rsvm.o
>>> icc -std=gnu99 -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -wd188 -ip -fp-model precise  -c cmeans.c -o cmeans.o
>>> icc -std=gnu99 -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -wd188 -ip -fp-model precise  -c cshell.c -o cshell.o
>>> icc -std=gnu99 -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -wd188 -ip -fp-model precise  -c floyd.c -o floyd.o
>>> icpc -I/apps/R/3.1.3-intel/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O3 -fp-model precise  -c svm.cpp -o svm.o
>>> icpc -L/usr/local/lib64 -o e1071.so Rsvm.o cmeans.o cshell.o floyd.o svm.o
>>> /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
>>> (.text+0x20): undefined reference to `main'
>>> Rsvm.o: In function `do_cross_validation':
>>> /tmp/Rtmp9h7iYE/R.INSTALL1d9615a42180e/e1071/src/Rsvm.c:91: undefined reference to `GetRNGstate'
>>> /tmp/Rtmp9h7iYE/R.INSTALL1d9615a42180e/e1071/src/Rsvm.c:94: undefined reference to `unif_rand'
>>> /tmp/Rtmp9h7iYE/R.INSTALL1d9615a42180e/e1071/src/Rsvm.c:106: undefined reference to `PutRNGstate'
>>> ... (many more undefined references)
> 
> -- 
> Andy Jacobson
> andy.jacobson at noaa.gov
> 
> NOAA Earth System Research Lab
> Global Monitoring Division
> 325 Broadway R/GMD1
> Boulder, Colorado 80305
> 
> 303/578-2237
> 
> 
> 
> 
> 
> 
-----------------------------------------------------------------------
This message and its attachments are strictly confidenti...{{dropped:8}}



[Rd] shlib problems with Intel compiler
Martyn Plummer