Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error installing from source in R under Termux #358

Closed
rrodrigueznt opened this issue Oct 1, 2021 · 8 comments
Closed

Error installing from source in R under Termux #358

rrodrigueznt opened this issue Oct 1, 2021 · 8 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@rrodrigueznt
Copy link

rrodrigueznt commented Oct 1, 2021

Hi! Installation in this environment:

~ $ radian --version
radian version: 0.5.12
r executable: /data/data/com.termux/files/usr/lib/R/bin/R
r version: 4.1.0
python executable: /data/data/com.termux/files/usr/bin/python3
python version: 3.9.7
~ $

Fails with the error:

* installing *source* package ‘cli’ ...
** package ‘cli’ successfully unpacked and MD5 sums checked                                                     ** using staged installation
** libs                                                 
gcc -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG   -I/data/data/com.termux/files/usr/include   -fpic  -g -O2  -c cleancall.c -o cleancall.o               
gcc -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG   -I/data/data/com.termux/files/usr/include   -fpic  -g -O2  -c errors.c -o errors.o                     
gcc -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG   -I/data/data/com.termux/files/usr/include   -fpic  -g -O2  -c init.c -o init.o                         
gcc -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG   -I/data/data/com.termux/files/usr/include   -fpic  -g -O2  -c progress-altrep.c -o progress-altrep.o   
gcc -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG   -I/data/data/com.termux/files/usr/include   -fpic  -g -O2  -c progress.c -o progress.o                 
gcc -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG   -I/data/data/com.termux/files/usr/include   -fpic  -g -O2  -c thread.c -o thread.o                     
thread.c:29:3: warning: implicit declaration of function 'pthread_setcanceltype' is invalid in C99 [-Wimplicit-function-declaration]                                      pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old);                                                       ^                                                     
thread.c:29:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'                                 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old);                                                                             ^                               
thread.c:80:11: warning: implicit declaration of function 'pthread_cancel' is invalid in C99 [-Wimplicit-function-declaration]                                              
ret = pthread_cancel(tick_thread);                            ^                                             2 warnings and 1 error generated.                       
make: *** 
[/data/data/com.termux/files/usr/lib/R/etc/Makeconf:168: thread.o] Error 1                            
make: *** Waiting for unfinished jobs....               
ERROR: compilation failed for package ‘cli’             
* removing ‘/data/data/com.termux/files/usr/lib/R/library/cli’                                                  
ERROR: dependency ‘cli’ is not available for package ‘pillar’                                                   
* removing ‘/data/data/com.termux/files/usr/lib/R/library/pillar’                                               
ERROR: dependency ‘pillar’ is not available for package ‘tibble’                                                
* removing ‘/data/data/com.termux/files/usr/lib/R/library/tibble’                                                                                                       
The downloaded source packages are in                           ‘/data/data/com.termux/files/usr/tmp/RtmpX0GyDU/downloaded_packages’                                    
Updating HTML index of packages in '.Library'           
Making 'packages.html' ... done                         
Warning messages:                                       
1: In install.packages("tibble") :                        
installation of package ‘cli’ had non-zero exit status
2: In install.packages("tibble") :                        
installation of package ‘pillar’ had non-zero exit status                                                     3: In install.packages("tibble") :                        
installation of package ‘tibble’ had non-zero exit status                                                                                                             r$>

Same error when I use R console.

Please, any clue? Thanks!

@gaborcsardi
Copy link
Member

Can you try this? its-pointless/gcc_termux#126 (comment)

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Oct 1, 2021
@rrodrigueznt
Copy link
Author

rrodrigueznt commented Oct 2, 2021

Thanks. I'm not sure if I'm following the instructions correctly. Here what I have:

~ $ echo $PKG_LIBS
-lbthread
~ $

Same error. Please, any idea? Thanks!

@gaborcsardi
Copy link
Member

The same exact error? Did you install libbthread? You need to set PKG_LIBS in the ~/.R/Makevars file.

@rrodrigueznt
Copy link
Author

rrodrigueznt commented Oct 2, 2021

I hope this describe what I'm doing:

~ $ ls ../usr/lib/libb*
../usr/lib/libbfd-2.37.so  ../usr/lib/libblkid.so
../usr/lib/libbfd.a        ../usr/lib/libbthread.so
../usr/lib/libbfd.la       ../usr/lib/libbz2.so
../usr/lib/libbfd.so       ../usr/lib/libbz2.so.1.0
../usr/lib/libblas.so      ../usr/lib/libbz2.so.1.0.8

~ $ head cli/src/thread.c

#include "cli.h"

#ifdef ANDROID
#include <bthread.h>
#endif

#include <pthread.h>
#include <time.h>
#ifndef _WIN32

~ $ cat .R/Makevars
export PKG_LIBS="lbthread"
~ $

I think the error is the same:

thread.c:33:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old);

Only the line changed after editing thread.c.

@gaborcsardi
Copy link
Member

This works for me:

#include "cli.h"

#include <pthread.h>
#ifdef __TERMUX__
#include <bthread.h>
#endif

#include <time.h>
#ifndef _WIN32
#include <signal.h>
#endif

and ~/.R/Makevars has to be

PKG_LIBS=-lbthread

@gaborcsardi
Copy link
Member

I can update thread.c in cli, but the Makevars is tricker because cli does not currently has a Makevars file, so I would need to generate one from configure.

Btw. set ~/.R/Makevars like this, note the plus sign:

PKG_LIBS+=-lbthread

then it should not break other packages. So if you leave this Makevars file in place then you'll not need anything special for the next version of cli.

@rrodrigueznt
Copy link
Author

It is working like a charm! Cli already installed. Other packages on their way! Thanks!

It is still hard to me to understand what I did following your advise. I'll keep reading and, hopefully, when I face a new issue I'll be able to take into account what I learned here!

Allow me to add here a link to a Stack Overflow thread I consider relevant for this issue:

https://stackoverflow.com/questions/43597632/understanding-the-contents-of-the-makevars-file-in-r-macros-variables-r-ma

Cheers!

@gaborcsardi
Copy link
Member

Let's keep this open, until I fix thread.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants