Eclipse CDT Cross Platform Development Within A Chroot Environment

This post is about how to configure eclipse to work with a chroot environment that is setup for cross compiling against ARM architecture.

Please refer to my post <a href="/?p=594">Cross Compile Pandaboard PowerVR OpenGL ES2 Example</a> if you want to know how to setup a chroot environment for cross compiling.

1. Install sudo and configure sudo

Install sudo:

apt-get install sudo

Allow every user that is within the sudo group to execute the chroot command without entering a password by adding the line to /etc/sudoers:


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

2. Prepare the project

The project must be located within the within the chroot environment. You could use bind mounts to create a mountpoint that connects your workspace project with a folder inside the chroot enviroment. I just placed the project itself inside the chroot environment and created a symlink that points to my workspace. Keep in mind to close your project or eclipse if you move the project files outside of eclipse.

  • 1. Create your CDT project.

  • 2. Close the project within eclipse.

  • 3. Move the project directory from e.g.: ~/workspace/MyProject/ to ~/mychroot/opt/MyProject

  • 4. Create a symlink inside of ~/workspace with the name <i>MyProject</i> that points to ~/mychroot/opt/MyProject

  • 5. Open the project within eclipse

3. Create a external build script

This example script (e.g: ~/workspace/MyProject/ will execute the bash command inside of the chroot environment which is located at $HOME/mychroot. The bash command will switch into the project location inside the chroot environment and execute make. Of course you can optimize the script to make it more generic and so on. But for now i’ll keep it simple.

sudo chroot $HOME/mychroot/  bash -c 'cd /opt/MyProject/; make clean; make'

4. Configure your eclipse cdt project

Now we have to change the builder for our project. Since we don’t want to use the host environment to build the project we need to tell eclipse to use our script which we created earlier. Go into <i>project properties → C/C++ Build → Builder Settings</i> and select External builder. Point the Build command to your

To fix syntax errors within your project you have to add the correct includes of course. Go to <i>project properties → C/C++ Build → Setting → Tool Settings</i> and add the include directories from your chroot enviroment. If you are using xapt to install cross libraries please note that those files are usually located at /usr/arm-linux-gnueabi/.

Example for libx11-dev

root@NeXuS:/# dpkg -L  libx11-dev-armel-cross