skip to Main Content

Dear Stackflow Community,

I’m trying to install the R "curl" package from source using a specialized R CMD INSTALL script on Debian 11 x86_64 machine. The source package downloads and build fine but when the linker tries to link libcurl to the source package, the linker can’t seem to find my libcurl package and the build fails. I’ve read others have had similar issues with not being able to local the libcurl package and have followed all prior suggested solutions (including ensuring I have the appropriate libcurl developement files downloaded from Debian distribution as noted in the resultant error message). R itself is installed and runs fine and can install packages from CRAN, but I need a source build for a special project.

Any suggestions? Thanks!

Here is the output of my attempt to build libcurl from source:

Screenshot

2

Answers


  1. It’s arguably tricky, but it helps to step back:

    • There is an CRAN package called curl. If you look at its CRAN page you will notice the hint SystemRequirements: libcurl: libcurl-devel (rpm) or libcurl4-openssl-dev (deb)

    • Because on Unix / Linux system there is an (extremely popular, widely used) library called curl and on Debian you get it as a run-time via the libcurl* package (with different ssl implementations).

    • And to build against the (C language) curl library (as opposed to the R package) you need (as the package says) the development package libcurl4-openssl-dev

    Because this is hard, "we" (as Debian developers) also try to give you binary Debian package of the key CRAN packages. I think we up to a bit over 1000 of thousand of those (out of 18.7 thousand CRAN packages). So do

    sudo apt install r-cran-curl
    

    and you will get a pre-compiled curl package for CRAN along with whatever run-time dependencies your system does not (yet) have (R, the libcurl* I mentioned etc)

    Edit Full log in a Docker session using Debian testing (as that is how I build Rocker’s r-base image that is also the officual r-base):

    edd@rob:~$ docker run --rm -ti rocker/r-base bash
    root@31cda2e7378e:/# apt update -qq
    70 packages can be upgraded. Run 'apt list --upgradable' to see them.
    root@31cda2e7378e:/# apt install libcurl4-openssl-dev
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Suggested packages:
      libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev libssl-dev
    The following NEW packages will be installed:
      libcurl4-openssl-dev
    0 upgraded, 1 newly installed, 0 to remove and 70 not upgraded.
    Need to get 463 kB of archives.
    After this operation, 1,732 kB of additional disk space will be used.
    Get:1 http://deb.debian.org/debian testing/main amd64 libcurl4-openssl-dev amd64 7.85.0-1 [463 kB]
    Fetched 463 kB in 0s (9,482 kB/s)            
    debconf: delaying package configuration, since apt-utils is not installed
    Selecting previously unselected package libcurl4-openssl-dev:amd64.
    (Reading database ... 18520 files and directories currently installed.)
    Preparing to unpack .../libcurl4-openssl-dev_7.85.0-1_amd64.deb ...
    Unpacking libcurl4-openssl-dev:amd64 (7.85.0-1) ...
    Setting up libcurl4-openssl-dev:amd64 (7.85.0-1) ...
    root@31cda2e7378e:/# root@31cda2e7378e:/# Rscript -e 'install.packages("curl")'                   
    Installing package into ‘/usr/local/lib/R/site-library’                                                                                                                                                            (as ‘lib’ is unspecified)                                                                                
    trying URL 'https://cloud.r-project.org/src/contrib/curl_4.3.3.tar.gz'                                                                                                                                             Content type 'application/x-gzip' length 670416 bytes (654 KB)                   
    ==================================================                                                                                                                                                                 downloaded 654 KB                                                                                        
                                                                                                                                                                                                                       * installing *source* package ‘curl’ ...                                                                 
    ** package ‘curl’ successfully unpacked and MD5 sums checked                                                                                                                                                       ** using staged installation                                                                             
    Found pkg-config cflags and libs!                                                                                                                                                                                  Using PKG_CFLAGS=-I/usr/include/x86_64-linux-gnu                                                         
    Using PKG_LIBS=-lcurl                                                                                    
    ** libs
    rm -f curl.so callbacks.o curl.o download.o escape.o fetch.o form.o getdate.o handle.o ieproxy.o init.o interrupt.o multi.o nslookup.o reflist.o split.o ssl.o typechecking.o utils.o version.o winidn.o writer.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wform
    at -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c callbacks.c -o callbacks.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wform
    at -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c curl.c -o curl.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wform
    at -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c download.c -o download.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wform
    at -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c escape.c -o escape.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wform
    at -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c fetch.c -o fetch.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wform
    at -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c form.c -o form.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c getdate.c -o getdate.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c handle.c -o handle.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c ieproxy.c -o ieproxy.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c init.c -o init.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c interrupt.c -o interrupt.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c multi.c -o multi.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c nslookup.c -o nslookup.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c reflist.c -o reflist.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c split.c -o split.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c ssl.c -o ssl.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c typechecking.c -o typechecking.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c utils.c -o utils.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c version.c -o version.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c winidn.c -o winidn.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -ffile-prefix-map=/build/r-base-J8F88F/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c writer.c -o writer.o
    gcc -shared -L/usr/lib/R/lib -Wl,-z,relro -o curl.so callbacks.o curl.o download.o escape.o fetch.o form.o getdate.o handle.o ieproxy.o init.o interrupt.o multi.o nslookup.o reflist.o split.o ssl.o typechecking.o utils.o version.o winidn.o writer.o -lcurl -L/usr/lib/R/lib -lR
    installing to /usr/local/lib/R/site-library/00LOCK-curl/00new/curl/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
    ** checking absolute paths in shared objects and dynamic libraries
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (curl)
    
    The downloaded source packages are in
            ‘/tmp/RtmpORcfhX/downloaded_packages’
    root@31cda2e7378e:/# 
    
    Login or Signup to reply.
  2. I understand you are compiling R packages to WASM using webR. The R curl package is a wrapper for the libcurl C library. So in order to build a wasm version of this package, you probably first need to figure out how to get a wasm port of libcurl.

    This won’t be an easy task because WASM doesn’t have IO capabilities. I think the only networking that a wasm module can do by interacting with the JavaScript code that it was loaded from, and that limits you to fetch/websockets. I don’t see right now how libcurl could be ported to wasm, but maybe I am wrong.

    But in short: I’m afraid it is impossible currently to compile the curl package, or other R packages requiring advanced networking, in webR right now. The webR port itself is patched to use XHR (ajax requests) for download.file() in order to support install.packages() and so on, but this is only a small subset of the capabilities of libcurl.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search