ethz-asl / programming_guidelines

This repository contains style-guides, discussions, eclipse/emacs auto-formatter for commonly used programming languages
139 stars 38 forks source link

Generating eclipse project using catkin tools #18

Closed tcies closed 10 years ago

tcies commented 10 years ago

How do you do it? If I do

catkin build --merge-devel --force-cmake --cmake-args -G"Eclipse CDT4 - Unix Makefiles"

I get:

[nlopt] ==> '/home/titus/catkin_ws/build/nlopt/build_env.sh /usr/bin/cmake /home/titus/catkin_ws/src/nlopt -DCATKIN_DEVEL_PREFIX=/home/titus/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/titus/catkin_ws/install -GEclipse CDT4 - Unix Makefiles' in '/home/titus/catkin_ws/build/nlopt'
CMake Error: Could not create named generator Eclipse
[nlopt] <== '/home/titus/catkin_ws/build/nlopt/build_env.sh /usr/bin/cmake /home/titus/catkin_ws/src/nlopt -DCATKIN_DEVEL_PREFIX=/home/titus/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/titus/catkin_ws/install -GEclipse CDT4 - Unix Makefiles' failed with return code '1'

Probably due to: http://stackoverflow.com/questions/16073040/call-cmake-from-python-script-results-in-could-not-create-named-generator

I currently found a workaround by:

cd build
cmake ../src/ -DCATKIN_DEVEL_SPACE=../devel -DCMAKE_INSTALL_PREFIX=../install -G"Eclipse CDT4 - Unix Makefiles"

As inspired by: http://catkin-tools.readthedocs.org/en/latest/commands/catkin_build.html?highlight=cmake#understanding-the-build-process

tcies commented 10 years ago

See #19

mbuerki commented 10 years ago

great stuff!!! thanks alot! I have just given it a try, and it failed to resolve the includes properly. could have to do with the merged development space.

does it work when using the '--merge-devel' tag for building the workspace? or only without it? or does it not matter at all?

simonlynen commented 10 years ago

@mbuerki if you add VERBOSE=1, setup the parser and do a fresh build it should find them.

mbuerki commented 10 years ago

it doesn't help. the problem probably lies in a somewhat screwed up workspace at my end of some reason. so there's the '~/catkin_aslam/devel/include' folder. this folder shows up in the eclipse project includes. however, I only have a very few number of packages in that folder with exported headers (i.e. gflags, ceres, suitesparse, and some more). it's lacking most of the aslam packages though. is this correct? i.e. if I have a project using the aslam/backend/optmizer2.hpp, should there be a 'backend' folder with the optimizer2.hpp file in the '.../devel/include' directory? (that's not the case at my place) or should it find that header somewhere else? (then that directory is missing in the eclipse includes)

simonlynen commented 10 years ago

@mbuerki It does not necessarily need the packages in there. If you clean out a package (by deleting the folder catkin_ws/build/$PACKAGE and then build it from within eclipse with VERBOSE=1, then the parser of eclipse will read the output of the compiler, more specifically the -I(...)/include/$PACKAGE statements and thereby find the includes. It is important though that an actual build is executed.

mbuerki commented 10 years ago

hm when I delete the project folder in 'catkin_aslam/buid' I can't build the project in eclipse anymore (says "no rule to make target 'all'). it seems like there's something really stupid I'm missing here, but I tried to follow the tutorial carefully...

markusachtelik commented 10 years ago

I can have a look at it later - on the run currently

Am 30.05.2014 um 20:30 schrieb "mbuerki" notifications@github.com<mailto:notifications@github.com>:

hm when I delete the project folder in 'catkin_aslam/buid' I can't build the project in eclipse anymore (says "no rule to make target 'all'). it seems like there's something really stupid I'm missing here, but I tried to follow the tutorial carefully...

— Reply to this email directly or view it on GitHubhttps://github.com/ethz-asl/programming_guidelines/issues/18#issuecomment-44683917.

simonlynen commented 10 years ago

ok, you of course need to run cmake for this package again, otherwise your makefile is gone, issue a catkin_build and cancel it once your package has started building. In any case the important part is that you actually build from within eclipse, however you trigger that.

tcies commented 10 years ago

Maybe a "make clean" would be more helpful here. Afaik this can be done from within Eclipse as well. Then you're sure that all sources will be compiled (thus feeding eclipse all the include dirs) without losing the makefile. Let me know if that works for you, I can add it to the tutorial then.

mbuerki commented 10 years ago

yes, works! awesome!!! it's resolving the 'size_t's again ;-) hahaha! great!

tcies commented 10 years ago

Ok, awesome :) . I updated the article, see second to last paragraph of https://github.com/ethz-asl/programming_guidelines/wiki/Catkin-Eclipse#adding-a-catkin-package-as-project-to-eclipse

mbuerki commented 10 years ago

oh crap, I was too fast. it still doesn't resolve the size_t's probably! it's not thinking they are ambiguous, once defined in stddefs.h and once in c++config.h.

in the includes, I have listed both /usr/include/c++/... and /usr/lib/gcc/x86-64-linux-gnu/4.6/include is that the problem? if yes, should I try to remove one of the two includes? if yes, which one? ... and how?

simonlynen commented 10 years ago

What exactly do you mean by size_t resolution? I don't see how this is an issue.

mbuerki commented 10 years ago

the size_t's get underlined with this redish curly line indicating that eclipse cannot figure out what it is (saying it's ambiguous with the details stated above)

simonlynen commented 10 years ago

OK, well then just switch this stupid eclipse feature off :)

cyborg-x1 commented 8 years ago

What about debuging? I sourced .bashrc_additions like that

bash -c 'source /home/cyborg-x1/.bash_additions; $pathtoeclipse/eclipse"

I created this file because of the "interactivity"-check which is normal for the bashrc. To run/debug I searched for the file in devel and added it. Running works fine so far but on debug I get:

No source available for "main() at 0x409f96"

(In that package I have two nodes btw) Am I missing something?

HannesSommer commented 8 years ago

Did you double check that you compiled your executable with debug symbols (-g) ? (For cmake this is typically achieved with CMAKE_BUILD_TYPE=Debug or similar. See http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html)

cyborg-x1 commented 8 years ago

Where exactly shall I put this in eclipse? I tried the builder settings but it did not do anything there.