'Installation of package ‘bigmemory’ had non-zero

I have installed bigmemory version 4.4.14. Now I am trying to upgrade it to bigmemory version 4.6.1 and got following error msg:

/usr/bin/ld: cannot find -luuid collect2: error: ld returned 1 exit status make: *** [/usr/share/R/share/make/shlib.mk:10: bigmemory.so] Error 1 ERROR: compilation failed for package ‘bigmemory’

  • removing ‘/home/super/R/x86_64-pc-linux-gnu-library/4.2/bigmemory’
  • restoring previous ‘/home/super/R/x86_64-pc-linux-gnu-library/4.2/bigmemory’ Warning in install.packages : installation of package ‘bigmemory’ had non-zero exit status

I have tried to upgrade via:

 Rstudio (Tools -> check for package update).

 install.packages("bigmemory")

 devtools::install_github("kaneplusplus/bigmemory")

Updated and upgraded ubntu and R packages:

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install r-base-dev

sudo apt install r-cran-bigmemory

update.packages(ask = FALSE)

install.packages("~/R/x86_64-pc-linux-gnu-library/4.2/bigmemory_4.6.1.tar.gz", repos = NULL, type = "source")

sessionInfo() R version 4.2.0 (2022-04-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.4 LTS

Matrix products: default BLAS:
/usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
LC_TIME=en_US.UTF-8 LC_COLLATE=en_GB.UTF-8
LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_GB.UTF-8
LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils
datasets methods base

loaded via a namespace (and not attached): [1] compiler_4.2.0 tools_4.2.0

I am struggling from few days but still getting the same problem, any help will be highly appreciated.



Solution 1:[1]

There are no problems with the implementation of this algorithm[1]. This algorithm returns the least power of 2, provided it is greater than or equal to the variable userInput:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int userInput, result;

    do{
        printf("Enter a number (-1 to exit): ");
        scanf("%d", &userInput);
    
        if (userInput > 0){
            result = 1;
            int counter = 0;
            
            while (result < userInput){
                result *= 2;
                printf("Result: %d\t Counter: %d\n", result, counter++);
            }
        
            printf("Result: %d ^ %d = %d\n", 2, counter, (int) pow(2, counter));
            printf("Minimum power of 2 greater than %d: %d\n", userInput, result);
        }
    
    } while (userInput != -1);

    return EXIT_SUCCESS;
}

In the above application, if the user enters the value 11, the following result is produced:

Enter a number (-1 to exit): 11
Result: 2       Counter: 0
Result: 4       Counter: 1
Result: 8       Counter: 2
Result: 16      Counter: 3
Result: 2 ^ 4 = 16
Minimum power of 2 greater than 11: 16

1 - Smallest power of 2 greater than or equal to n

Solution 2:[2]

Change to this:

while (result < userInput)
{
   printf("Before: %d\n");
   result *= 2;
   printf("After: %d\n\n");
}

And you'll see what's going on.

Solution 3:[3]

...
    result = 1;
    while (result < userInput)
    {
       result *= 2;
    }
...

Every time result is tested and it's lesser than userInput, result is doubled.
In the case of 5 as userInput

iterations result userInput
at start 1 5 (>result so continue looping)
iteration 1 2 5 (>result so continue looping)
iteration 2 4 5 (>result so continue looping)
iteration 3 8 5 (<result so loop stops)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 klutt
Solution 3