What I usually do: cpp files are in src folder, h files in include/my_package folder
eg. for files:
src/main.cpp
src/my_class.cpp
include/my_package/my_class.h
CMakeLists.txt will then use:
rosbuild_add_executable(binary_name src/main.cpp src/my_class.cpp)
But there are many ways to achieve the same. You can look at how other packages are structured and choose the one that you like. OR you can look at REP122 to see how the file system hierarchy is done for ROS packages
Originally posted by weiin with karma: 2268 on 2012-08-20
This answer was ACCEPTED on the original site
Post score: 3
Original comments
Comment by Rydel on 2012-08-21:
why would my_class need to be compiled into an executable?
Comment by weiin on 2012-08-21:
good question, I don't know the "correct" answer, but I do know the compiler complains if you don't. :) There are other ways like putting the class file into a library (as suggested by Sivam) or use -lpath flag. I think the bottomline is, the compiler needs to know where the class files are.
Comment by weiin on 2012-08-21:
This explains a bit on the linking of headers: http://www.unix.com/programming/47881-help-compiling-header-files-c-file-using-gcc.html