-
Notifications
You must be signed in to change notification settings - Fork 0
Eclipse
First of all install the Eclipse IDE from their website into the /opt folder. Now we create a Desktop entry which lets you startup Eclipse from the launcher panel within the ROS environment:
- Create the following file and enter:
sudo gedit /usr/share/applications/eclipse.desktop
- Adapt the followig code to reflect your system:
[Desktop Entry]
Name=Eclipse
Type=Application
Exec=bash -i -c "source /opt/ros/kinetic/setup.bash && source /home/USERNAME/CATKIN_WS/devel/setup.bash && /opt/eclipse/eclipse"
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE
Name[en]=eclipse.desktop
where you should adapt USERNAME and CATKIN_WS to yourself.
- Go into your catkin workspace and build everything using the following command:
catkin build --force-cmake -G"Eclipse CDT4 - Unix Makefiles"
Optionally you can additionally use the -DCMAKE_BUILD_TYPE=Debug argument in case code should be compiled for debugging. 2. Run the following script from the root of your workspace to create the required .project files:
ROOT=$PWD
cd build
for PROJECT in `find $PWD -name .project`; do
DIR=`dirname $PROJECT`
echo $DIR
cd $DIR
awk -f $(rospack find mk)/eclipse.awk .project > .project_with_env && mv .project_with_env .project
done
cd $ROOT
Go to Window->Preferences->C/C++->Build->Settings and select the "Discovery" tab. In "CDT GCC Build Output Parser [ Shared ]" prepend ".*" to the regular expressions, e.g.:
(.*gcc)|(.*[gc]\+\+)|(.*clang)
On same page check "Project" for "Container to keep discovered entries". Then, in "CDT GCC Built-in Compiler Settings [ Shared ]" add the "-std=c++11" flag to obtain e.g.:
${COMMAND} -E -P -v -dD -std=c++11 "${INPUTS}"
File → New → Project... → C/C++ -> Makefile Project with Existing Code Now choose a name and give the location of the catkin_ws/src folder, choose LinuxGCC and finish.
- Right click on the project you just created and go to "Properties" -> "C/C++ Build" -> "Environment" and add a variable VERBOSE with value 1, add to all configurations and apply.
- In "C/C++ General"->"Paths and Symbols", tab "Symbols", add
__GXX_EXPERIMENTAL_CXX0X__
in "GNU C++" with no value and apply. - Go to "C/C++ General"->"Preprocessor Includes", "Providers" tab. Check "CDT GCC Build Output Parser" and "CDT GCC Built-in Compiler Settings" and verify that you "Use global provider shared between projects" in both. Then press apply and ok.
- Right click on the project and go to "Properties" -> "C++-General" -> "Paths and Symbols"
- In the "Includes" tab select "GNU C++" under "Languages" click "Add" and add:
/usr/include/c++/5
/usr/include/x86_64-linux-gnu/c++/5
[PATH_TO_CATKIN_WS]/devel/include
- In the "Libraries" tab make sure you have an entry "stdc++".
- In the "Library Paths" tab click "Add" and add:
/usr/lib/gcc/x86_64-linux-gnu/5
- Go to "C/C++ General" -> "Indexer", and click on "Enable project specific settings" and "Allow heuristic resolution of includes".
- Next go to Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Built-In Compiler Settings, add "-std=c++11" to the command line, i.e. it should say
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" -std=c++11
- Now rebuild the index by right clicking on the project and under "Index" select "Rebuild".
- Right click on your Project -> Properties -> C/C++ Build tab → Manage Configuration → New
- Name your build configuration. In the Builder Settings tab
- Build command:
catkin build PACKAGE_NAME --force-color --no-status -v -j8
- Build directory:
/home/USERNAME/CATKIN_WS/build
- In the Behavior tab edit: Build (incremental build)
""
and Clean--make-args clean
Another option is to use Eclipsify and import every package separate. This has the advantage that most of the settings are already done. However, in order to get good linkage between the different files, lots of packages need to be imported which can be very annoying for large projects.
- Go to the root of your catkin workspace and type:
eclipsify -s -W devel/ CATKIN_PACKAGE
- File -> Import -> Existing Projects into Workspace -> Select the root directory: Browse... -> Choose your catkin_ws/src. Then "Deselect All" and then only select the package you want and Finish.
- Then right click on the freshly added package and go to Properties → C/C++ General → Preprocessor Include Paths, Macros etc. -> Providers -> CDT GCC Build Output Parser -> check "Use global provier shared between projects"
- Clean project by right clicking on it -> "Clean Project" and then build it "Build Project".