Search code examples
eclipse-cdtchroot

How to build to chroot using Eclipse CDT?


I've got a chroot environment with everything needed for building a complex C++ project, using make (it's for a specific Linux distribution).

I would like to use Eclipse CDT (outside the chroot environment) in this project but make it so that Eclipse, when building, goes into the chroot enviroment and builds in there.

Is it possible?


Solution

  • Yes thats possible. Just select the 'External builder' within the Builder Settings Tab under C/C++ Build. I selected a script that executes the following commands:

    sudo chroot $HOME/mychroot/  bash -c 'cd /myproject-location/; make clean; make'
    

    To avoid a password check i added the following line to my /etc/sudoers file:

    %sudo   ALL= NOPASSWD: /usr/sbin/chroot
    

    To avoid wrong build failure/syntax error reporting you have to add the include files from within your chroot environment to the eclipse cdt project.