I had installed R-3.1.2 on Ubuntu using the commands
wget http://cran.r-project.org/src/base/R-3/R-3.1.2.tar.gz
tar xvfz R-3.1.2.tar.gz
cd R-3.1.2
./configure
make
sudo make install
When I tried to launch RStudio I got the error
R shared library (/usr/local/lib/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option?
So I went back and tried to reconfigure with
./configure --enable-R-shlib=yes
make
But I got the error
collect2: error: ld returned 1 exit status
make[3]: *** [libR.so] Error 1
make[3]: Leaving directory `/usr/local/lib/R-3.1.2/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/usr/local/lib/R-3.1.2/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/usr/local/lib/R-3.1.2/src'
make: *** [R] Error 1
When searching stack overflow, I found an answer here: How to configure R-3.0.1 with --enable-R-shlib that suggested that the problem was that I was trying to compile in a directory that I had previously compiled without the "--enable-R-shlib" option
I tried to fix the problem by using the commands
make uninstall
which gives no errors by many "Nothing to be done for `uninstall'." statements, but it did successfully uninstall R
./configure --enable-R-shlib=yes
which gives the error
config.status: error: cannot find input file: `src/library/base/DESCRIPTION.in'
then
make
which gives the same error as when I tried to make before.
Can you help me see where I have gone wrong?
make uninstall
only undoes the make install
step, which generally copies the files from the compilation dir to dir(s) on the system as appropriate, and puts binaries in say /usr/bin
so they are on the path. If you wanted to clean up the dir where you did a previous compile, use make clean
(or make distclean
, I forget what the difference is now as far as R is concerned but convention is that it should return the build dir to pre-configure, pre-build state.).
You also, in general, don't want to be building in the dir which contains the R sources (which ./configure
suggests you are doing).
make clean
is the way to go; here to add some further words of clarification on what's going on.
You attempted to build R with the wrong options (ie, without using --enable-R-shlib
as is required to use it with RStudio), and in the process did either a full or a partial build of R.
Your error message says the issue arose in ./src/main
, where the earlier make
compiled the .c
files there into the .o
files. When you re-run make
after re- ./configure
-ing with the right options, it sees those .o
files and says "I don't need to re-compile the .c
files here, .o
files already exist" and attempts to proceed.
However, those .o
files were compiled under a different configuration, so they are "stale" in that sense -- make clean
removes those .o
files (as well as any other artefacts of the earlier build that are now obsolete).
There may be a more minimal way of resetting your build ( make clean
removes all built files from the earlier make
, but maybe only some subset of those is required), but this would probably depend on what exactly is the difference between the earlier ./configure
options and the new ones, and you're apt to spend more time tinkering than it would take to just do a clean build (personally, I gave up after removing all the ./src/main/*.o
files wasn't enough).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.