termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.4k stars 3.09k forks source link

Package Request: R (r-base) #250

Open tomtom opened 8 years ago

tomtom commented 8 years ago

Several users of GnuRoot Debian reported that R works on arm. Currently there is no other way to run R on Android.

dm319 commented 8 years ago

this would be great!

muyang commented 8 years ago

I find one way to install R. (1) install Fedora see https://nmilosev.svbtle.com/fedora-on-nonrooted-android-phones-2016-update (2) install R yum install R *(3) install KDE yum|dnf install @kde-desktop

its-pointless commented 7 years ago

Umm https://github.com/its-pointless/gcc_termux I actually have an experimental build of R in termux.

namdnguyen commented 7 years ago

@its-pointless thanks for sharing this! Could you describe the installation process a bit more? I tried extractions the files and then modifying the executive files permissions, but I get an error that R can't load libiconv.so.2. Should I be installing it differently?

Grimler91 commented 7 years ago

@namdnguyen follow the instructions in @its-pointless's readme instead, or look at the detailed steps isaacullah provided in this thread.

With this, you can install it as a normal package with packages install r-cran and get updates.

namdnguyen commented 7 years ago

@Grimler91 Thank you for the quick reply! I was able to install r-cran with isaacullah's instructions. However, I am still having some trouble getting R to run. I still get the same message, which I'll include below.

CANNOT LINK EXECUTABLE: could not load library "libiconv.so.2" needed by "/data/data/com.termux/files/usr/lib/R/bin/exec/R"; caused by library "libiconv.so.2" not found

I've tried uninstalling and reinstalling iconv to see if that would help, but it doesn't. Any ideas on what I could try next? Am I skipping a necessary step from the README without realizing it?

its-pointless commented 7 years ago

I will fix it later today ... to compile R needs a more functioning libiconv to compile than is in libandroid-support Thought i made sure it was functioning.

its-pointless commented 7 years ago

wait if its asking for that lib that means the executable is the old version

its-pointless commented 7 years ago

no wait its arm version that is the problem my mistake

its-pointless commented 7 years ago

https://github.com/its-pointless/gcc_termux/blob/master/libiconv.so.2.6.0 is what you want

namdnguyen commented 7 years ago

Thank you. I copied that to $PREFIX/lib and renamed it to libiconv.so.2 and that message went away, but then it gave a similar message and said that mempcpy was missing.

its-pointless commented 7 years ago

Oh im about deal with that. Its due to differences between devices since you kind of have to build this on device.

A work around is to find a lib with that has that symbol On your device do nm -A -D /system/lib/lib*.so | grep mempcpy A lib with T memcpy is what you want then LD_PRELOAD=/system/lib/libTHELIB.so R

its-pointless commented 7 years ago

Also if you haven't set TMP variable it will complain about not being able to create R_TempDir ...

namdnguyen commented 7 years ago

Oh ok, no rush. I really appreciate how incredibly responsive you've been. I will wait.

I did try out the workaround you mentioned. I wasn't able to find any libs with mempcpy, but there were a lot with memcpy without the "p".

namdnguyen commented 7 years ago

@its-pointless just to confirm, R is working for me now after the latest update. Thank you so much for your contributions! I now have R and ledger on my phone.

wickx commented 7 years ago

hi, @its-pointless, thanks for this. being able to run R on termux is fantastic. after adding the link to the sources.list, running and update and then

packages install r-cran

the installation was really easy. unfortunately, when i try to launch R, i get this error message:

CANNOT LINK EXECUTABLE: library "libicuuc.so.59" not found page record for 0x7f81152050 was not found (block_size=64)

any ideas?

thanks again. very useful work. with termux, it's getting to the point where i won't be bound to my laptop anymore. if i could only get R to work... :)

its-pointless commented 7 years ago

apt install libicu should be enough i will add dependency

wickx commented 7 years ago

f** brilliant!

it's working. just did a quick install of quantmod, quandl, etc in R. couldn't be happing. it's the latest version of R as well.

i had been messing around with GNURoot Wheezy but this is far superior to anything else out there.

if anyone is wondering how to get R working on android. follow these steps:

  1. install termux
  2. edit your sources.list, by adding the link to the its-pointless repo (see above)
  3. add the key (i didn't bother)
  4. run an update: apt-get update
  5. install this lib: apt install libicu
  6. wait
  7. and finally: packages install r-cran

and you'll be good to go. thanks a lot for this, @its-pointless. this is definitely better than any of the other suggestions online. and i'm glad to see people contributing to termux development, it's a game-changer

namdnguyen commented 7 years ago

I'm having trouble installing the Rcpp package. I get this error message.

api.cpp:39:18: fatal error: 'execinfo.h' file not found #include

Does anyone have any tips or ideas?

its-pointless commented 7 years ago

Android isn;t defined as an option but its easy to add defined(__ANDROID__). https://github.com/its-pointless/gcc_termux/tree/master/R-patches i will be putting any patches needed for r stuff there.

wickx commented 7 years ago

just another update for anyone who's having issues with R on termux. there are a lot of additional packages you need to install within termux itself, make sure you do

packages install clang packages install libgfortran

amongst others (cant remember all of them). then, when you're in R itself, and you try to install quantmod (for instance)

install.packages('quantmod')

you'll get an error message that the gfortran command can't be found (even though you've installed libgfortran). in tht case, navigate to the

/usr/bin

directory and run this command

cp gfortran-6 gfortran

i have no idea if you're meant to do tht (??) but making a copy of this file with a title tht R recognises worked for me! i can pull financial data through quantmod and quandl and plot it inside a pdf. very happy. now i just have to figure out the equivalent of 'gnome-open' in termux, so tht i can open pdfs directly from the terminal...

its-pointless commented 7 years ago

yeah i probably should of added more documentation. First thing install gcc-6 should install libgfortran. but if its not listed as a dep thats my fault.

Second point because clang is the default and gcc was removed i setup a script called setupclang and setupgcc-6 to switch between those 2 compilers. It also switches aarch64-linux-android-clang to be a symlink to gcc because of the way python configuration is set linking is sometimes done with aarch64-linux-android-clang not just just $CC. I should probably document it more but i honestly thought no one is going to use it but me so i stopped caring... anyway if you have any further suggestions im all ears.

wickx commented 7 years ago

i'll use it! most definitely. i couldn't be happier right now. i just think a lot of people aren't aware tht this exists yet. all the various dependencies aside, getting R on android now basically comes down to installing termux and running one command. and considering how much i use R in my day to day job, this is really invaluable. thanks.

namdnguyen commented 7 years ago

Yes, I will second what @wickx said. It's been so helpful for me to have R available on my phone. I'm currently working on getting the tidyverse packages installed. Some of the packages installed (thanks to Rcpp and the gcc-6 compiler), but I think that others (such as stringi) require some fixes in the scripts to fix the shebang with termux-fix-shebang, and installing from source.

its-pointless commented 7 years ago

Yeah issue with stringi is that it uses libicu-dev which needs cxxflags -std=c++11 to work if i remember correctly. Quickest solution is to use command setupgcc-6, build and install stringi then switch back to via setupclang . i will get a patch up in a bit.

its-pointless commented 7 years ago

Also export CONFIG_SHELL=$PREFIX/bin/sh helps.

cptrodolfox commented 7 years ago

Hello, I am having problems to install r-cran when I try to use packages install r-cran I get the output unable to locate package r-cran. I have installed the repository and even I have installed libicu. Thank you in advance,

wickx commented 7 years ago

hey cptrodolfox, i'm going to use emacs in this example because tht's the text editor i use. feel free to use another. to install emacs, it's

packages install emacs

then, enter the following command to edit your sources.list file, this is the file tht determines what repositories you access when you do an install or update command

emacs $PREFIX/etc/apt/sources.list

once inside the file, move your cursor to the bottom of the file, and paste this line

deb [trusted=yes] https://its-pointless.github.io/files/ termux extras

once you've done that, hit ctrl+x ctrl+s to save and then ctrl-x ctrl+c to exit emacs. after you've exited emacs, run these commands

packages update packages install r-cran

and R should be installed. to launch R, just type the capitalised letter R on the command line and hit enter.

you'll prolly encounter more issues inside R once you start using it. report back what they are and i should be able to help you, as i currently have R running pretty flawlessly.

cptrodolfox commented 7 years ago

Hi wickx, I have already have done that adding the repository and the key, and done the apt-get update. But, when I try packages install r-cran, It does not locate the package. It hits both repository the main termux and its-pointless one. Thank you in advance

its-pointless commented 7 years ago

currently its only for arm and aaarch64. Since its compiled on device since R no longer support cross compiling. Is your device x86?

when you do apt update could you print the output here?

cptrodolfox commented 7 years ago

Hi its-pointless,

The architecture I think is aarch64 as I have installed other packages and does was their architevture. The output of apt update is: apt update Hit:1 http://termux.net stable InRelease Hit:2 https://its-pointless.github.io/files termux InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Thanks in advance

its-pointless commented 7 years ago

i guess you could try direct download and then dpkg -i whatever.deb for now and download directly from https://github.com/its-pointless/its-pointless.github.io/tree/master/files/dists/termux/extras/binary-aarch64 but i don't know what could be causing this.

wickx commented 7 years ago

yeh, me neither

have you tried

packages search r-cran

if you can't see it then you've probably entered the pointless repo in wrong

cptrodolfox commented 7 years ago

Hi, The output of packages search r-cran is: packages search r-cran Hit:1 http://termux.net stable InRelease Hit:2 https://its-pointless.github.io/files termux InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Sorting... Done Full Text Search... Done

cptrodolfox commented 7 years ago

I finally found the error, I have a small typo at the end of the line of my source.list. Now I have installed r-cran.

Thank you,

vishalbiswas commented 7 years ago

@fornwall R has been requested by a lot of people. @its-pointless It may be wise to create a pull request.

wickx commented 7 years ago

hey @cptrodolfox no problem. glad i could help :)

@vishalbiswas

agreed.

its-pointless commented 7 years ago

few reasons that is more complicated than you realize. It needs the ndk recompiled to support fortran It requires gcc compiler to be resurrected it needs the gcc compiler on device to support fortran it needs blas to be compiled. To get a good blas on arm i had to do something retarded with atlas blas otherwise its 30-40% slower. R can only be compiled on device it hasn't supported cross compiling since 2.9 its now 3.4. Had this conversation already.

seannossek commented 7 years ago

@its-pointless @wickx i'm a researcher who's pretty new to linux - i've been trying to get r running on my pixel c for some time using gnuroot debian to no avail. Do you think one of you might find the time to post a 'how-to' on running r using termux for someone with little-to-no linux experience? I read through the posts but wasn't able to get it working.

Would be much appreciated!!

its-pointless commented 7 years ago

a script to do everything automatically https://its-pointless.github.io/setup-pointless-repo.sh

Just execute this on device sh setup-pointless-repo.sh

apt install r-cran should work then. if you don't know how to get it on device because linux is all new apt update apt upgrade then install wget apt install wget wget https://its-pointless.github.io/setup-pointless-repo.sh

wickx commented 7 years ago

Hi @seannossek

can you be more specific about the issue you're facing? i'd be more than happy to do a tutorial but i'm working on a few different things currently so shan't be able to do one for a while. in the meantime, i could address any specific issues you're facing...

have you tried its-pointless' suggestion above?

seannossek commented 7 years ago

@its-pointless @wickx sorry I've just gotten around to trying this

its-pointless's script worked perfectly installing R, this is invaluable so i can't thank you enough.

unfortunately i'm incountering errors trying to install the package i need to use (it's a text analysis package called 'stylo')

when i attempt install i get the message that tcltk2, along with several other dependencies, are unavailable and I cannot install them. funny enough I encountered exactly this problem using the 64-bit version of R on windows (though 32- bit ran correctly), so i'm not sure if the problem is with the package or using R in termux

its-pointless commented 7 years ago

The tcltk library in base r-cran is used mainly for the gui elements. We don't have xwindows which means we don't have tk which means we can't load the tcltk library in R. Tcltk2 requires tcltk. So until we get x windows support working in anyway (someone is actually working on this but it uses a software renderer not the accelerated graphics in android it could load R tcltk possibly) i am afraid you are out of luck.

namdnguyen commented 7 years ago

Hi @its-pointless, it seems like you were able to compile stringi. I think I mostly got there. I did the following steps:

It seemed to compile fine, but then I get this message at the end.

** testing if installed package can be loaded Error: package or namespace load failed for ‘stringi’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/data/data/com.termux/files/usr/lib/R/library/stringi/libs/stringi.so': dlopen failed: cannot locate symbol "_ZdaPvj" referenced by "stringi.so"... Error: loading failed Execution halted ERROR: loading failed

  • removing ‘/data/data/com.termux/files/usr/lib/R/library/stringi’ Warning message: In install.packages("/data/data/com.termux/files/home/projects/stringi", : installation of package ‘/data/data/com.termux/files/home/projects/stringi’ had non-zero exit status
its-pointless commented 7 years ago

when linking appears to work but it still missing symbols either the code is wrong or the linker is wrong. My guess is its the issue with 5.1 linker. Since you have had a similar issue before but with a different symbol.

nm -A -D /system/lib/lib*.so | grep ZdaPvj find which lib is not loading. Add it to ld flags when compiling the library. So if the missing symbol is in libcompiler_rt.so add -lcompiler_rt etc.

eeenilsson commented 7 years ago

Thanks for this!

I got the following when trying to run R:

CANNOT LINK EXECUTABLE ".../com.termux/files/usr/lib/R/bin/exec/R": library "libandroid-glob.so" not found

its-pointless commented 7 years ago

Amusingly enough apt install libandroid-glob ahould fix that. I will fix dependencies so it should install properly next update.

eeenilsson commented 7 years ago

Thanks! Works with the fix above.

eeenilsson commented 7 years ago

Has anyone got ess (Emacs speaks statistics) working with R on termux?

xraynaud commented 7 years ago

Hello, I m having trouble making R start. It's complaining:

CANNOT LINK EXECUTABLE: cannot locate symbol "mempcpy" referenced by "/data/data/com.termux/files/usr/lib/R/bin/exec/R"... I think I have installed all the packages discussed on this page (libgfortran, clang, gcc-6...) and all their dependencies. The command nm -A -D /system/lib/lib*.so | grep mempcpy does not return anything. Could somebody tell me in which package function mempcpy is? Thanks.