In a previous question I asked about creating a chroot that simulates my embedded device environment. It was suggested that I build from source GCC and binutils first inside my chroot. To attempt this I copied the version of libc and gcc binary on my host machine to the chroot. I then wrote a simple hello world program to a file test.c and tried to build in my chroot as follows

  phil@phil-desktop:/usr$ sudo chroot /usr/embedded_chroot1/
  bash-4.2# gcc test.c 
  gcc: error trying to exec 'cc1': execvp: No such file or directory

I am not too sure what is going on here with this error. I have copied the gcc binary and libc to my chroot so why am I unable to compile? Must I copy all system source and header files into my chroot also?? I think I have a conceptual misunderstanding with the whole process of using a chroot.

  • Have a look at this so question Jul 16 '12 at 14:08
  • @UlrichDangel So gcc is not actually the compiler?? Thanks for this link. I am slowly beginning to realise why Linux/Unix experts get paid such good salaries. Jul 16 '12 at 14:19
  • 1
    It is a little bit more complicated but gcc is basically an wrapper/frontend and will run the appropriate command which in your case is cc1 but could also be cc1plus for c++. Either way you should try to contact your vendor how to create a build chroot/environment for your system Jul 16 '12 at 14:51
  • Ah thanks for this. The vendor offers absolutely no support whatsoever for this. I guess that at least means that I have no option but to run Ubuntu on my device and built it on an equivalent setup on my dev machine Jul 16 '12 at 14:52

The gcc build has the ability to bootstrap itself without any existing compiler on the system. You should be able to download and unpack gcc, and build it inside your chroot without having to copy anything from outside. It has been a while since I've done this, but I remember it was reasonably painless.

Look at the build instructions for gcc, which detail this process. You will want to build a native compiler, and all the steps should be performed inside your chroot, so that gcc will be built to match that system.

  • Ah great - that sounds like a lot less pain than what I am trying to do at the moment. I will try this approach instead Jul 16 '12 at 14:53
  • I am having a lot of trouble with it as there is no makefile but I will accept this answer as its clearly a far better way of doing it that my current method. Jul 16 '12 at 15:50
  • Oops, I gave you the wrong instructions link :) Sorry, I'll update the question. Check out this instead: gcc.gnu.org/install
    – mrb
    Jul 16 '12 at 16:10
  • Thanks for the corrected link. Even the documentation looks painful. Jul 16 '12 at 19:16

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.