baddstats / polyclip

R package polyclip: a port of the Clipper library for polygon geometry
19 stars 6 forks source link

Cannot build CRAN version on Archlinux #14

Open adrfantini opened 5 years ago

adrfantini commented 5 years ago

It seems I cannot build the latest version of polyclip from CRAN:

polyclip  (1.9-1        -> 1.10-0      ) [CRAN]
* installing *source* package ‘polyclip’ ...
** package ‘polyclip’ successfully unpacked and MD5 sums checked
compiling under C++11
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpBWZVcr/R.INSTALL5a5c1b30658f/polyclip':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘polyclip’

All other packages get built properly, do you have any idea why this version cannot compile? My system (ArchLinux) is up to date, using gcc 8.2.1+20181127-1.

EDIT: cannot build GH version either:

Downloading GitHub repo baddstats/polyclip@master
✔  checking for file ‘/tmp/RtmpOQ14Nf/remotes7b0f46cf3775/baddstats-polyclip-b761add/DESCRIPTION’ ...
─  preparing ‘polyclip’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘polyclip_1.10-0.tar.gz’

Installing package into ‘/home/adriano/.R_libs’
(as ‘lib’ is unspecified)
* installing *source* package ‘polyclip’ ...
compiling under C++11
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpK9z9GQ/R.INSTALL75a631b8e67c/polyclip':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘polyclip’
baddstats commented 5 years ago

The report says that the config.log contains more details. Please attach the config.log

The report says that the C++ compiler cannot create files (presumably because it does not have permission).

adrfantini commented 5 years ago

I understand this, but there is no config.log inside the indicated /tmp/... folder. Where should I be able to find it?

baddstats commented 5 years ago

I have no idea. Try manually downloading the polyclip tar file and manually installing it. Or consult someone who understands the Archlinux system.

adrfantini commented 5 years ago

I installed polyclip successefully by running R with sudo, so it's a permission problem. No other package seems to show the same behaviour, tho.

Here is the install output:

* installing *source* package ‘polyclip’ ...
** package ‘polyclip’ successfully unpacked and MD5 sums checked
compiling under C++11
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
Using PKG_CONFIG: pkgconf
Compiling against bundled copy of clipper library.
     In the clipper library, signed 64-bit integers (cInt)
     will be declared as 'signed long long'
     In the clipper library, unsigned 64-bit integers (cUInt)
     will be declared as 'unsigned long long'
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -I"/usr/include/R/" -DNDEBUG -DPOLYCLIP_LONG64="signed long long" -DPOLYCLIP_ULONG64="unsigned long long"  -D_FORTIFY_SOURCE=2   -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt  -c init.c -o init.o
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -DPOLYCLIP_LONG64="signed long long" -DPOLYCLIP_ULONG64="unsigned long long"  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c interface.cpp -o interface.o
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -DPOLYCLIP_LONG64="signed long long" -DPOLYCLIP_ULONG64="unsigned long long"  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c clipper.cpp -o clipper.o
g++ -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o polyclip.so init.o interface.o clipper.o -L/usr/lib64/R/lib -lR
installing to /home/adriano/.R_libs/polyclip/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (polyclip)

Feel free to close if you want to.

gowachin commented 4 years ago

Same issue on Ubuntu 18.04, but does not work with 'sudo R'. No config.log to found on my system...

baddstats commented 4 years ago

This is not quite the same issue, because it is not fixed by using sudo R.

Does the error message say "C++ compiler cannot create executables"?

If so, then this problem is not caused by the polyclip package, but is related to the R installation and the system permissions.

gowachin commented 4 years ago
> install.packages('polyclip')
Installation du package dans ‘whatever_my_folder/R/x86_64-pc-linux-gnu-library/3.4’
(car ‘lib’ n'est pas spécifié)
essai de l'URL 'https://cloud.r-project.org/src/contrib/polyclip_1.10-0.tar.gz'
Content type 'application/x-gzip' length 79619 bytes (77 KB)
==================================================
downloaded 77 KB

   Welcome to R!

* installing *source* package ‘polyclip’ ...
** package ‘polyclip’ correctement décompressé et sommes MD5 vérifiées
compiling under C++11
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpqJIrOr/R.INSTALL1e3d740cecc1/polyclip':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘polyclip’
* removing ‘whatever_my_folder/R/x86_64-pc-linux-gnu-library/3.4/polyclip’

Les packages source téléchargés sont dans
    ‘/tmp/Rtmp1BbZ0C/downloaded_packages’
Warning message:
In install.packages("polyclip") :
  l'installation du package ‘polyclip’ a eu un statut de sortie non nul

I don't understand where it's failing, as other packages compile nice. And I tested this lignes in R, and it worked...so I guess you can close it now. I really don't understand how, but as it works \o/

library(devtools)
install("polyclip")
rubak commented 4 years ago

@gowachin Just out of curiosity can you install other packages that compile C++ code from source without problems? E.g.

install.packages("nloptr", type = "source")
gowachin commented 4 years ago

@rubak It works without problems

rubak commented 4 years ago

This is quite strange. And you say it also works without any problems when you use devtools::install()? I really don't see any good reason why this should work while install.packages() doesn't. What if you download the tar.gz source from CRAN first and then install directly from that file?

install.packages("polyclip_1.10-0.tar.gz", repos = NULL)
gowachin commented 4 years ago

It works with devtools::install(), but it doesn't work with install.packages() (wether i use 'polyclip' or your line) and return :

compiling under C++11
checking whether the C++ compiler works... no

I don't know a lot a stuff about R, but yeah, really strange.

darachm commented 4 years ago

I've got the same behavior as gowachin, plus a minor observation.

Running this on 18.04 Ubuntu, I can't install via install.packages() from CRAN or from local tgz file. Running R CMD INSTALL on the tgz from the command line didn't work, nor did a sudo R CMD INSTALL. These all fail and report that checking whether the C++ compiler works... no .

Downloading, un-compressing the package to a polyclip folder, then running devtools::install("polyclip") from either interactive session or from Rscript will install the package nicely.

The error appears to come from the configure file in the archive. If I extract the archive, then run configure, it runs fine outside of R. It is only in the context of R's install.packages() that it can't find the right compiler. Weird.

ismailsunni commented 4 years ago

I got the same problem when I try to install polyclip on MRO inside Ubuntu 18.04 docker container. I can install it by using @darachm 's way.

wget https://cran.r-project.org/src/contrib/polyclip_1.10-0.tar.gz
tar -zxvf polyclip_1.10-0.tar.gz
Rscript -e "library('devtools'); devtools::install('polyclip')"
cobac commented 4 years ago

Just had this problem running ArchLinux as well. I fixed it by running R with sudo.

MaxKman commented 4 years ago

I have the same issue when trying to install the package on Debian 10.

Jadamso commented 4 years ago

Same issue on Fedora 32. Other install's work fine. E.g., install.packages("nloptr") passes. This solution worked

wget https://cran.r-project.org/src/contrib/polyclip_1.10-0.tar.gz
tar -zxvf polyclip_1.10-0.tar.gz
Rscript -e "library('devtools'); devtools::install('polyclip')"
rubak commented 4 years ago

It would be great if someone was able to provide a reproducible example in a docker container, so we could investigate further.

ismailsunni commented 4 years ago

@rubak try this

docker run -it --rm nuest/mro:3.5.3

then from the MRO (it's already launched MRO from the command above), run

install.packages('polyclip')
rubak commented 4 years ago

Thanks @ismailsunni. Is it also reproducible with GNU-R? I expect it is easier to get help from the mailing lists that way.

ismailsunni commented 4 years ago

hi @rubak Well, in my Ubuntu 18.04 and GNU R, it's working fine. I only get the problem with MRO. My GNU R is 3.4.4.

mpadge commented 11 months ago

@rubak I had the same issue on Archlinux, and found at least one cause. Your configure script hard-codes the C++ compiler to g++ and over-rides any local preferences for clang. But the initial configure.ac call defaults to local compiler preferences which may not be gcc. Compiling init.o with clang and then linking with other objects compiled with g++ as forced by your configure then errors.

.. .But that's not the only fix that'll be necessary, because the whole configure is also hard-coded for CXX11, which will not be acceptable for latest CRAN policies, so the entire configure setup will need to be updated. Hope that helps!!

Solution

Ensure local compiler options (for example, set via ~/.R/Makevars) are:

CXX=g++
CC=gcc

Thanks for trying so hard over so many years to investigate these issues - really appreciate the effort!

rubak commented 11 months ago

Thanks a lot for that explanation @mpadge :+1: We will try to fix the compiler (and CXX11) issue. I'm not sure if this covers all the problems seen by others where they can download the source and install from the local file but using install.packages() directly doesn't work. Shouldn't the compiler problem be the same in both cases if present?

mpadge commented 11 months ago

... not necessarily. The devtools workflows are complicated in the way they respect local compiler flags. I suspect also that your configure is entirely overwriting local flags, which devtools does not generally do. More generally, i suspect all issues can be traced back to compilers and/or compiler flags set or overwritten in your configure script.

rubak commented 11 months ago

Great. That sounds promising. Hopefully this could then solve the issue completely. Thanks again for pointing it out.

baddstats commented 11 months ago

@mpadge thank you very much for your advice. I will give you access to the full tree of development code for polyclip. If you can help us fix this, it would be greatly appreciated.