linux - Error compiling gcc on Raspberry Pi

07
2014-07
  • Harlandraka

    So, after solving the problems I had before (previous question here), I'm having some other trouble compiling gcc 2.95.3 on my Raspberry.

    This is what I get with the

    make bootstrap
    

    command.

    ../../gcc-2.95.3/gcc/config/arm/arm.c: In function ‘arm_override_options’:
    ../../gcc-2.95.3/gcc/config/arm/arm.c:286:20: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
    ../../gcc-2.95.3/gcc/config/arm/arm.c:530:17: error: lvalue required as left operand of assignment
    make[2]: *** [arm.o] Error 1
    make[2]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
    make[1]: *** [bootstrap] Error 2
    make[1]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
    make: *** [bootstrap] Error 2
    

    Can anyone help me? How can I make it compile?


    UPDATE

    After changing that variable name, I'm getting these errors:

    In file included from /usr/include/stdlib.h:25,
                     from ../../gcc-2.95.3/gcc/libgcc2.c:41:
    /usr/include/features.h:323: bits/predefs.h: No such file or directory
    /usr/include/features.h:356: sys/cdefs.h: No such file or directory
    /usr/include/features.h:388: gnu/stubs.h: No such file or directory
    In file included from ../../gcc-2.95.3/gcc/libgcc2.c:41:
    /usr/include/stdlib.h:42: bits/waitflags.h: No such file or directory
    /usr/include/stdlib.h:43: bits/waitstatus.h: No such file or directory
    /usr/include/stdlib.h:320: sys/types.h: No such file or directory
    In file included from ../../gcc-2.95.3/gcc/libgcc2.c:42:
    /usr/include/unistd.h:203: bits/posix_opt.h: No such file or directory
    /usr/include/unistd.h:207: bits/environments.h: No such file or directory
    /usr/include/unistd.h:218: bits/types.h: No such file or directory
    In file included from ../../gcc-2.95.3/gcc/libgcc2.c:42:
    /usr/include/unistd.h:606: bits/confname.h: No such file or directory
    make[4]: *** [libgcc2.a] Error 1
    make[4]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
    make[3]: *** [stmp-multilib-sub] Error 2
    make[3]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
    make[2]: *** [stmp-multilib] Error 1
    make[2]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
    make[1]: *** [bootstrap] Error 2
    make[1]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
    make: *** [bootstrap] Error 2
    
  • Answers
  • MariusMatutiae

    Luckily for you, this is an old problem. I too had it, and solved it by looking it up with Google.

    In the file arm.c (/gcc/config/arm), line 530 as per the error message above, correct the line as follows:

      arm_prgmode = TARGET_APCS_32 ? PROG_MODE_PROG32 : PROG_MODE_PROG26;
    

    I have no idea how this silly mistake percolated into the code, and how it evaded detection. But alas, there it is.

    EDIT:

    The second error is not very specific, might be due to many factors. For instance, is your PATH variable empty?

      echo $PATH
    

    If it echoes something like

      /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    

    then you are Ok, otherwise

      export PATH= /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    

    will solve the problem.

    Or you may need to install/re-install the libc6-dev libraries. In this case,

      sudo apt-get purge libc6-dev
      sudo apt-get install libc6-dev
    

    Alternatively, you may try to use (I found this very convenient) a pre-built tool-chain, available from here: https://github.com/raspberrypi/tools. Even if you know what you are doing, going through a seemingly endless list of compilation errors trying to identify all the pieces you are missing can be tiresome.


  • Related Question

    linux - arm-uclinux-gcc: crt1.o not found
  • Hamish Milne

    I recently installed the arm-uclinux toolchain from arm-uclinux-tools-base-gcc3.4.0-20040610.sh . I ran the script and tried to compile a test program:

    /usr/local/arm-uclinux-tools/bin/arm-uclinux-gcc hello.c -o hello
    
    /usr/local/arm-uclinux-tools/lib/gcc/arm-uclinux/3.4.0/../../../../arm-uclinux/bin/ld.real: crt1.o: No such file: No such file or directory
    collect2: ld returned 1 exit status
    

    I searched for hours about this issue and found nothing, except a hint about uclibc not being installed. Isn't it compiled along with the toolchain?

    I'm using Ubuntu 11 64 bit.


  • Related Answers
  • Simon Sheehan

    Take a look at this thread. If you'd rather just skip to the point, here's a quote from it

    "Try using the command g++ instead of gcc. The g++ command is used for compiling C++ code (whereas gcc defaults to C code), and will automatically link against libstdc++.so. If you really want to use gcc to compile, you must manually tell it to link against the c++ library, e.g. "

    $ gcc foo.cpp -l stdc++