I am trying to compile a C program on Ubuntu precise 12.04. Here's the program:

#include <stdio.h>

int main(int argc, char** argv) {
  printf("Hello World!");
  return 0;

My gcc version is 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5). Initially it did not find cc1 so I added a soft link. Now I get this message when I try to compile:

gcc: internal compiler error: Segmentation fault (program cc1)

Compiling the same program with g++ works fine.

I tried reinstalling build-essential, but to no avail. What am I missing?

EDIT: I tried reinstalling according to @gertyvdijk's suggestion. As it did not help, here is the output of apt-cache policy gcc-4.6:

  gcc-4.6:  Installed: 4.6.3-1ubuntu5
  Candidate: 4.6.3-1ubuntu5
  Version table:
 *** 4.6.3-1ubuntu5 0
        500 http://il.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status

and the output of ls -l /usr/bin/gcc:

lrwxrwxrwx 1 root root 7 Mar 13  2012 /usr/bin/gcc -> gcc-4.6

EDIT #2: here's a verbose compiler output:

    gcc -v aaa.c 
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1 -quiet -v -imultilib . -imultiarch x86_64-linux-gnu aaa.c -quiet -dumpbase aaa.c -mtune=generic -march=x86-64 -auxbase aaa -version -fstack-protector -o /tmp/ccHfcXMs.s
gcc: internal compiler error: Segmentation fault (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
  • 1
    Try cc <filename.c>.
    – green
    Jun 26, 2013 at 8:42
  • 1
    "I tried reinstalling build-essential" - That's just a metapackage. You'll have to reinstall the plain GCC packages to properly reinstall all gcc binaries. Try apt-get reinstall gcc gcc-4.6 gcc-4.6-base libgcc1. If that does not work, please also provide the output of apt-cache policy gcc-4.6 and ls -l /usr/bin/gcc in your question.
    – gertvdijk
    Jun 26, 2013 at 9:09
  • Did not work. Please see the updated question.
    – Yuval F
    Jun 26, 2013 at 9:30
  • 2
    GCC package installation looks all good. I am unable to reproduce this using the exact same gcc version and the source you provided - binary returns "Hello World!" as expected. It could be that a Bash alias in your user profile is the culprit. Could you try to invoke gcc using this more explicit command?/usr/bin/gcc sourcefile.c -o helloworld. Oh and I meant sudo apt-get install --reinstall gcc gcc-4.6 gcc-4.6-base libgcc1 in my previous comment. (there's no such action as apt-get reinstall.)
    – gertvdijk
    Jun 26, 2013 at 9:36
  • 1
    Re-reading "Initially it did not find cc1 so I added a soft link." <-- What exactly did you do and why? I now think you mean /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1 from the cpp-4.6 package - was it absent? It should just be there - it's a hard dependency of gcc. Try reverting the symbolic link you created and reinstall that package.
    – gertvdijk
    Jun 26, 2013 at 11:18

1 Answer 1


This segmentation fault really should not happen. I suspect something is wrong with the binaries installed on your system - possibly because of the symbolic link you created.

Try reinstalling GCC and all affecting libraries:

sudo apt-get install --reinstall gcc gcc-4.6 gcc-4.6-base libgcc1 cpp-4.6

Specifically the cpp-4.6 Install cpp-4.6 package appears to be broken in your setup as /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1 belongs to that package and the error output you've provided indicates the cause of the issue is in there somewhere.

  • The version need to be the same as the installed cc1. In my case was 4.8 "/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1". So the command sudo apt-get install --reinstall gcc gcc-4.8 gcc-4.8-base libgcc1 cpp-4.8 did the trick
    – Amadu Bah
    Jun 1, 2014 at 10:36
  • Still getting the 'segmentation fault'
    – Nathan B
    Sep 20, 2017 at 11:00
  • Thanks, the following worked for me: sudo apt-get install --reinstall gcc gcc-4.9 gcc-4.9-base libgcc1 cpp-4.9 Note: this is actually on Raspian Jessy.
    – Geoff
    Dec 31, 2017 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.