How to build chroot using Eclipse CDT?

I have a chroot environment with everything I need to create a complex C ++ project using make (for a specific Linux distribution).

I would like to use the Eclipse CDT (outside the chroot environment) in this project, but make sure that Eclipse, when it was being built, goes into the chroot environment and is built there.

Is it possible?

+4
source share
2 answers

Yes it is possible. Just select "External Builder" on the "Builder Options" tab in the "C / C ++ Build" section. I selected a script that executes the following commands:

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

To avoid password verification, I added the following line to the / etc / sudoers file:

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

To avoid the erroneous assembly / syntax error message, you need to add the included files from the chroot environment to the eclipse cdt project.

+3
source

A slightly more elegant way is to create a script compile.sh

 #!/bin/bash sudo chroot $HOME/mychroot bash -c 'cd /workspace/'$1'/; make '$2 

and in eclipse write this to an external builder

 /pathto/compile.sh ${ProjName} 

This makes partial builds possible, as build targets are passed to chroot.

+3
source

All Articles