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

Installation fails on Termux #349

Open
rrodrigueznt opened this issue Oct 3, 2021 · 17 comments
Open

Installation fails on Termux #349

rrodrigueznt opened this issue Oct 3, 2021 · 17 comments
Labels
help wanted ❤️ we'd love your help!

Comments

@rrodrigueznt
Copy link

rrodrigueznt commented Oct 3, 2021

Hi! Installing from source on R 4.1.0 on Termux, I get this error:

id.cc:109:17: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?                            passwd* pwd = getpwent();                                             ^~~~~~~~                                                getgrent                                /data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here                             static struct group* getgrent(void) { return 0; }                            ^                                  id.cc:109:11: error: cannot initialize a variable of type 'passwd *' with an rvalue of type 'struct group *'      passwd* pwd = getpwent();                                       ^     ~~~~~~~~~~                              id.cc:113:11: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?                              pwd = getpwent();                                             ^~~~~~~~                                                getgrent                                      /data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here                             static struct group* getgrent(void) { return 0; }                            ^                                  id.cc:113:11: error: incompatible pointer types assigning to 'passwd *' from 'struct group *'                       pwd = getpwent();                                             ^~~~~~~~~~                                    4 errors generated.                                     make: *** [/data/data/com.termux/files/usr/lib/R/etc/Makeconf:173: id.o] Error 1                                make: *** Waiting for unfinished jobs....               ERROR: compilation failed for package ‘fs’              * removing ‘/data/data/com.termux/files/usr/lib/R/library/fs’

Please, any idea? Thanks!

@rrodrigueznt rrodrigueznt changed the title Installation fails in Termux Installation fails on Termux Oct 3, 2021
@jimhester
Copy link
Member

It looks like there are a couple of patches at https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-id.cc.patch and https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-Makevars.patch, did you apply those?

@rrodrigueznt
Copy link
Author

Working on that! Thanks!

@rrodrigueznt
Copy link
Author

rrodrigueznt commented Oct 6, 2021

Working on that! Thanks!

I'm failing in my attempts of applying both patches. Here what I get:

~ $ git apply rcran-fs-Makevars.patch --verbose --ignore-whitespace
rcran-fs-Makevars.patch:5: trailing whitespace.
HOST :=
Checking patch fs/src/Makevars...
error: while searching for:
PKG_LIBS += -lkvm
endif
ifeq ($(UNAME), Linux)
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif


error: patch failed: fs/src/Makevars:18
error: fs/src/Makevars: patch does not apply
~ $
~ $ git apply rcran-fs-id.cc.patch --verbose --ignore-whitespace
Checking patch fs/src/id.cc...
error: while searching for:
List users_() {
  std::vector<std::string> names;
  std::vector<int> ids;
#ifndef __WIN32
  passwd* pwd = getpwent();
  while (pwd != NULL) {
    names.push_back(pwd->pw_name);

error: patch failed: fs/src/id.cc:69
error: fs/src/id.cc: patch does not apply
~ $

I guess both patches are outdated and shouldn't work as they are without editing and updating them. Please, am I correct?
I'm new to git. Please, is there anyway of getting updated patches? I'm not sure if my question has any sense. Thanks!

@jimhester
Copy link
Member

I think you could look at what the patches do and then apply the edits manually to the current sources.

@leechaowen
Copy link

i have compiled r-base 4.1.2 source code in termux for my phone today. how to fix such issue? Thanks.

> install.packages("fs")
trying URL 'https://mirrors.bfsu.edu.cn/CRAN/src/contrib/fs_1.5.0.tar.gz'
Content type 'application/octet-stream' length 796244 bytes (777 KB)
==================================================
downloaded 777 KB

* installing *source* package ‘fs’ ...
** package ‘fs’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c dir.cc -o dir.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c error.cc -o error.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c file.cc -o file.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c fs.cc -o fs.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c getmode.cc -o getmode.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c id.cc -o id.o
id.cc:109:17: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?
  passwd* pwd = getpwent();
                ^~~~~~~~
                getgrent
/data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here
static struct group* getgrent(void) { return 0; }
                     ^
id.cc:109:11: error: cannot initialize a variable of type 'passwd *' with an rvalue of type 'struct group *'
  passwd* pwd = getpwent();
          ^     ~~~~~~~~~~
id.cc:113:11: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?
    pwd = getpwent();
          ^~~~~~~~
          getgrent
/data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here
static struct group* getgrent(void) { return 0; }
                     ^
id.cc:113:11: error: incompatible pointer types assigning to 'passwd *' from 'struct group *'
    pwd = getpwent();
          ^~~~~~~~~~
4 errors generated.
make: *** [/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/etc/Makeconf:173: id.o] Error 1
ERROR: compilation failed for package ‘fs’
* removing ‘/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/fs’

The downloaded source packages are in
        ‘/data/data/com.termux/files/usr/tmp/RtmpadY3y2/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("fs") :
  installation of package ‘fs’ had non-zero exit status

@leechaowen
Copy link

It looks like there are a couple of patches at https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-id.cc.patch and https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-Makevars.patch, did you apply those?

how to use these patches? i have no knowledge about how to run patches. i think it's better update fs for termux. Could you mind take some time update it ? Thanks .

@gaborcsardi gaborcsardi added the help wanted ❤️ we'd love your help! label Dec 8, 2021
@gaborcsardi
Copy link
Member

I don't have termux, does libuv compile on termux?

I can consider patches to make fs compile on termux.

@leechaowen
Copy link

I don't have termux, does libuv compile on termux?

I can consider patches to make fs compile on termux.

Thanks your support. i run pkg install libuv in termux, show below.

~ $ pkg install libuv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libuv is already the newest version (1.42.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~ $

@rrodrigueznt
Copy link
Author

Hi! @gaborcsardi, @jimhester, it seems that the change introduced by https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-id.cc.patch is simple and easy to introduce at line 108 of the current version of id.cc in https://github.com/r-lib/fs/blob/main/src/id.cc. I guess I should fork the project, edit the file, and submit changes to the original repository with pull requests. Please, am I right? Thanks!

@gaborcsardi
Copy link
Member

gaborcsardi commented Dec 14, 2021

Yeah, please do that. Thanks!

@rrodrigueznt
Copy link
Author

rrodrigueznt commented Dec 15, 2021

Yeah, please do that. Thanks!

Done, I think! The message about getpwent() has gone. And using this Makevars:

https://github.com/rrodrigueznt/fs/blob/8e60e9e84fc244d9060f53b8d15cb4628d5751c3/src/Makevars

Here what I get now:

~ $ R CMD INSTALL fs --preclean
* installing to library ‘/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library’
* installing *source* package ‘fs’ ...
** using staged installation
** libs
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c dir.cc -o dir.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c error.cc -o error.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c file.cc -o file.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c fs.cc -o fs.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c getmode.cc -o getmode.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c id.cc -o id.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c init.cc -o init.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c link.cc -o link.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c path.cc -o path.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c utils.cc -o utils.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c unix/getmode.cc -o unix/getmode.o
gcc -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c bsd/setmode.c -o bsd/setmode.o
gcc -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c bsd/strmode.c -o bsd/strmode.o
gcc -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c bsd/reallocarray.c -o bsd/reallocarray.o
g++ -std=gnu++14 -shared -L/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/lib -L/usr/local/lib -o fs.so dir.o error.o file.o fs.o getmode.o id.o init.o link.o path.o utils.o unix/getmode.o bsd/setmode.o bsd/strmode.o bsd/reallocarray.o ./libuv-1.38.1/.libs/libuv.a -pthread -lbthread -L/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/lib -lR
installing to /data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/00LOCK-fs/00new/fs/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘fs’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/00LOCK-fs/00new/fs/libs/fs.so':
  dlopen failed: cannot locate symbol "uv__pthread_sigmask" referenced by "/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/00LOCK-fs/00new/fs/libs/fs.so"...
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/fs’
~ $

I don't find information about uv__pthread_sigmask.

Please, any idea? Thanks!

@gaborcsardi
Copy link
Member

pthread is lacking on Termux, see here: r-lib/cli#358 (comment) and the comments below.

@rrodrigueznt
Copy link
Author

Still working hard to understand where I am lost, I founded this pthread-sigmask.patch

@rrodrigueznt
Copy link
Author

pthread is lacking on Termux, see here: r-lib/cli#358 (comment) and the comments below.

I'm still lost. I'm afraid that I've no skills enough to understand why you are pointing me to my own comments in a different issue, and you say that pthread is lacking on Termux.

In Termux I find:

~ $ ls ../usr/lib/libpthr*                           
../usr/lib/libpthread.so
~ $ ls ../usr/include/pthread*
../usr/include/pthread.h
~ $

Please, does it mean that pthread is available on Termux? Also, here what I get when I try to list the symbols available in libpthread.so:

~ $ nm -gD ../usr/lib/libpthread.so
nm: ../usr/lib/libpthread.so: file format not recognized
~ $

However, I'm able to list them for any other installed library. Please, does it make any sense to you? Any further help will be truly appreciated! Thanks!

@gaborcsardi
Copy link
Member

Because libpthread is missing some functions on termux, that are provided by libbthread. Maybe this is why uv__pthread_sigmask is missing for you. But it is just a guess, I don't have a termux system, so I can't actually try any of this, sorry.

@kurokirasama
Copy link

kurokirasama commented May 28, 2022

someone has the right patches, the mentioned before do not work for me?

@yfyang86
Copy link

compile the libuv-1.44.2 manually should work. Although it is an ugly fix.

  • download the R package and extract it;

  • patch whatever the above threads told;

  • Compile libuv manunally

rm -rf fs/src/libuv-1.44.2`
cd fs/src
wget https://codeload.github.com/libuv/libuv/tar.gz/refs/tags/v1.44.2
tar vxf v1.44.2
cd libuv-1.44.2
mkdir .libs
cd .libs
cmake ..
make
cp -rf libuv* /data/data/com.termux/files/usr/lib
  • Change srv/Makevars
UNAME := $(shell uname)

LIBUV := libuv-1.44.2

PKG_LIBS = ./$(LIBUV)/.libs/libuv.so -pthread

SOURCES = $(wildcard *.cc unix/*.cc)
OBJECTS = $(SOURCES:.cc=.o)

ifeq ($(UNAME), SunOS)
PKG_LIBS += -lkstat -lsendfile -lsocket -lxnet
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif
ifeq ($(UNAME), FreeBSD)
PKG_LIBS += -lkvm
endif
ifeq ($(UNAME), OpenBSD)
PKG_LIBS += -lkvm
endif
ifneq ($(filter $(UNAME), Linux AIX OS400),)
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif

PKG_CPPFLAGS = -I./$(LIBUV)/include -I. -pthread

all: $(SHLIB)

$(SHLIB): $(LIBUV)/.libs/libuv.so

.PHONY: shlib-clean clean

# shlib-clean: clean

clean:
	$(MAKE) --directory=$(LIBUV) distclean
	rm -f $(OBJECTS)
  • INSTALL R package

In the folder the fs package locates

R CMD INSTALL fs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted ❤️ we'd love your help!
Projects
None yet
Development

No branches or pull requests

6 participants