Sorry. The file extension was the solution:

$ mv c c.c
$ gcc c.c
$ ./a.out
4096




Feb 10, 2019, 10:28 AM by znavko@tutanota.com:
Installation of gcc-toolchain did not help.

$ guix package -I |grep gcc
gcc-toolchain    8.2.0    out    /gnu/store/xwk99qi92pm3zqd95mvjx4mkdmg8plpk-gcc-toolchain-8.2.0

$ gcc c
c: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status

$ cat c
#include <sys/stat.h>
#include <stdio.h>

int main(void)
{
    struct stat stats;

    if (!stat("/", &stats))
    {
        printf("%u\n", stats.st_blksize);
    }
}



Feb 9, 2019, 2:35 PM by rekado@elephly.net:

znavko@tutanota.com writes:
Hi! I compile this https://stackoverflow.com/questions/6161823/dd-how-to-calculate-optimal-blocksize <https://stackoverflow.com/questions/6161823/dd-how-to-calculate-optimal-blocksize>

and get this:

$ gcc c.c
collect2: fatal error: cannot find 'ld'
compilation terminated.

$ whereis ld
ld:

$ gcc --version
gcc (GCC) 8.2.0

How to solve this?

I’m assuming that you installed the “gcc” package. Don’t do that.
Install “gcc-toolchain” instead.

guix package -r gcc -i gcc-toolchain

--
Ricardo