0
$\begingroup$

Rosanswers logo

PROBLEM:
When I use catkin_make to create the Eclipse project files, it does not include some standard system dependencies in the Include Paths, namely:

  • /usr/include/c++/4.6
  • /usr/include/c++/4.6/x86_64-linux-gnu
  • /usr/include/c++/4.6/backward

SPECIFICS:
I run

 $ catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles"

and import the project in Eclipse from the build directory. (see catkin and eclipse)
When I import the project in Eclipse, it is missing the above includes, which causes it to complain about - namely, among other things - "Unresolved include of #include < string >"

This in turn propagates errors of "Type std::string could not be resolved"

The package builds just fine, which means the compiler can resolve all required includes, this is just a problem in using Eclipse effectively.

QUESTION: Is there a way to have catkin build the Eclipse project files with those includes?

(SPECS: Groovy on Ubuntu 12.04)


Originally posted by dsolomon on ROS Answers with karma: 253 on 2013-04-23

Post score: 4


Original comments

Comment by William on 2013-04-23:
I think this is more of a question about CMake. If you make a simple CMake project and give it the -G"Eclipse.... argument are the include paths set correctly? If they are then we might need to look into why catkin is different, but otherwise I think this is a general CMake question.

Comment by dsolomon on 2013-04-23:
William, that set me on the right path. To work around my current problem, I added following two lines in my CMakeLists.txt: SET(STANDARD_INCLUDE_DIRS "/usr/lib/gcc/x86_64-linux-gnu/4.6/include; /usr/(...etc) ) include_directories(include ${STANDARD_INCLUDE_DIRS} ) There must be a more-correct way.

Comment by dsolomon on 2013-04-23:
So while this is an issue with CMake, it still feels like the auto-generated CMakeLists.txt files should have rules that account for this. The package has no problem building, so the directories are obviously included and linked properly, they just don't export to the eclipse project files.

Comment by demmeln on 2013-04-24:
FWIW I ran into the exact same issue (on 12.04 + groovy + catkin) before. It seems it is somehow related to catkin. Other cmake eclipse projects (in my case from rosbuild packages) work just fine without any special handling of the above include paths.

Comment by dsolomon on 2013-08-21:
I'm not sure why, but as of yesterday this issue was resolved for me. All expected include paths were present in the project settings. Anyone have any insights?

$\endgroup$

4 Answers 4

0
$\begingroup$

Rosanswers logo

It looks like the CMake Eclipse generator does not include these paths, because they are implicitly included by the compiler. It looks like you can either add them to you include path manually within CMake or you can globally configure eclipse to include them.

http://stackoverflow.com/questions/1564668/cmake-and-eclipse-default-include-paths

From that post, it seems like the suggestion is to add it to eclipse globally, as they pointed out it is redundant (and not portable) to put these paths in CMake manually and is not necessary as the builds succeed. Rather I think the better solution is to globally configure eclipse to add those by default for autocompletion and syntax checking purposes.


Originally posted by William with karma: 17335 on 2013-04-24

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by dsolomon on 2013-04-24:
I was using that before I modified CMakeLists, but each time Eclipse project files are regenerated (ie new dependancy added) all includes (including manually added external paths) are overwritten. Is there a command in CMake to make implicit includes explicit (ideally just for make eclipse project)?

Comment by William on 2013-04-24:
I don't know of one. I think the suggestion is to add the standard include paths above the project settings level, i.e. so that it applies to all projects. I have to do this in my editor even for non-catkin projects, but I don't know how or if you can do this in eclipse.

$\endgroup$
0
$\begingroup$

Rosanswers logo

I had the same problem. I am using eclipse CDT Kepler. To solve it, go to project properties, find 'preprocessor Include Paths', then under the tab 'providers' you will find 'CDT_GCC Built-in Compiler Settings'. Check it and that's it. It's better than to add all include dirs manually.


Originally posted by stomic with karma: 101 on 2013-07-30

This answer was NOT ACCEPTED on the original site

Post score: 10


Original comments

Comment by Boris on 2013-07-30:
Thanks! I use to add these paths by hand with "Add Contributed..."

$\endgroup$
0
$\begingroup$

Rosanswers logo

Here are some other problems I had and the solutions (rather workarounds) I've found:

  • Indexing in Eclipse fails, because Eclipse runs out of memory. Run eclipse with this option to increase max memory (source)

./eclipse -vmargs -Xmx2048m

  • I had indexing stability problems with both Juno and Kepler, so I reverted back to Indigo. It's seems to be indexing properly and stably, but the 'Preprocessor Include Paths' solution from stomic isn't available, so the headers need to added manually.
  • Here are my headers:

/usr/include/c++/4.6

/usr/include/c++/4.6/i686-linux-gnu

/usr/include/c++/4.6/backward

/usr/lib/gcc/i686-linux-gnu/4.6/include

/usr/include/i386-linux-gnu

  • In /usr/include/eigen3/Eigen: all headers are without a .h extension, so Eclipse can't find them... Create symbolic link for each header: ln -s SVD SVD.h
  • Create symbolic link of Eigen in /usr/include: ln -s eigen3/Eigen Eigen (Eclipse has problems finding subdirectories...).
  • Same problem with pcl in pcl-1.6, so copy the content of /opt/ros/groovy/include/pcl-1.6/pcl to /opt/ros/groovy/include/pcl

If anyone knows better concerning some of these issues, please let me know. I've spent quite a lot of time to figure this out, so I hope it will be of help to others.


Originally posted by bluebird11 with karma: 11 on 2013-08-30

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by mach on 2016-08-01:
This answer solves a problem which is not solved by @stomic's answer. Eigen ans pcl have real problems while including in eclipse

$\endgroup$
0
$\begingroup$

Rosanswers logo

I just ran into the same problem (no idea why this didn't happen before). Turns out that eclipse can't parse localized gcc messages, so the auto-discovery of standard include paths from the gcc output fails. Solution:
LC_ALL=C eclipse

Or, if you like that better: "Window -> Preferences -> C/C++ -> Build -> Environment", add two new environment variables "LANG" and "LC_ALL" and set them both to "en_US" or "C". Also see this eclipse forum post.

(Who actually wants localized error messages from gcc? The German translation usually makes them even more cryptic, IMO...)

Update: After trying to reproduce this on a fresh work space, it turned out that I was wrong, LC_ALL has nothing to do with it. @stomic's answer is correct. I had to follow these steps (Eclipse Juno, ROS Groovy):

  1. right-click Project -> C/C++ General -> Code Analysis -> Preprocessor Includes -> Providers -> "Enable language settings providers for this project", then enable only "CDT GCC Built-in Compiler Settings"
  2. remove project (but keep contents on disk), then import project again
  3. you may have to right-click Project -> Index -> Rebuild

Originally posted by Martin Günther with karma: 11816 on 2013-09-22

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.