Compiling ROS nodes needs the ROS environment. We have to source /opt/ros/indigo/setup.bash to access the ROS environment in the current terminal. We can work from the system terminal because we already added this line to the .bashrc file, but when we work using Eclipse, we have to make a script to do this.
Create a file called eclipsemake in /usr/local/bin using the following command:
$ sudo nano /usr/local/bin/eclipsemake
Enter the following commands in this file:
#!/bin/bash source /opt/ros/indigo/setup.bash make "$@" VERBOSE=1 -j8
Create another file called eclipsemake-tests for testing the purpose on the same path. Create a file using the following command:
$ sudo nano /usr/local/bin/eclipsemake-tests
Enter the following content into the file:
#!/bin/bash source /opt/ros/indigo/setup.bash make "$@" VERBOSE=1 -j8 run_tests
If you are using Eclipse in Virtual Box, use -j1 instead of -j8.
After creating these two files, change the permission of these two using the following command:
$ sudo chmod +x /usr/local/bin/eclipsemake*