# Revision history [back]

You are naming three totally different things with "putting". A class cannot be used by a service (if you mean a ROS service), you need to provide a service server implementation.

Regarding "putting" in the sense of file location: If other packages besides the one you are implementing are using the class it is good practice to put the header in include/mypackage/header.h, and include the file in your sources via #include "mypackage/header.h". In that case you should also take care of exporting c++ directives in the manifest.

If the header file is only used in the package you can put it in src/.

The .cpp files usually go in src/.

Regarding CMake, in most cases you don't need to put the headers in there.

You are naming three totally different things with "putting". A class cannot be used by a service (if you mean a ROS service), you need to provide a service server implementation.

Regarding "putting" in the sense of file location: If other packages besides the one you are implementing are using the class it is good practice to put the header in include/mypackage/header.h, and include the file in your sources via #include "mypackage/header.h". In that case you should also take care of exporting c++ directives in the manifest.

If the header file is only used in the package you can put it in src/.

The .cpp files usually go in src/.

Regarding CMake, in most cases you don't need to put the headers in there.there. If you create a new package the CMakeLists.txt already contains the commands for creating a library and exectable, you just need to uncomment them.

You are naming three totally different things with "putting". A class cannot be used by a service (if you mean a ROS service), you need to provide a service server implementation.

Regarding "putting" in the sense of file location: If other packages besides the one you are implementing are using the class it is good practice to put the header in include/mypackage/header.h, and include the file in your sources via #include "mypackage/header.h". In that case you should also take care of exporting c++ directives in the manifest.

If the header file is only used in the package you can put it in src/.

The .cpp files usually go in src/.

Regarding CMake, in most cases you don't need to put the headers in there. If you create a new package the CMakeLists.txt already contains the commands for creating a library and exectable, you just need to uncomment them.

Can you be more precise on what exactly you are doing, give a minimal example? Are you working in the same package or are you building a library package that you want to use in other packages? In the second case you need to export line in the manifest, but the term "-lros" is the linker directive for this package, i.e. instead of "-lros" it should be "-lmylib".

If class.h and class.cpp are in src/ and you have another source file in src/ you should be able to include and use class.h without a problem. If class.h is in include/mypackage/class.h, you should include that file using #include "mypackage/class.h".

You are naming three totally different things with "putting". A class cannot be used by a service (if you mean a ROS service), you need to provide a service server implementation.

Regarding "putting" in the sense of file location: If other packages besides the one you are implementing are using the class it is good practice to put the header in include/mypackage/header.h, and include the file in your sources via #include "mypackage/header.h". In that case you should also take care of exporting c++ directives in the manifest.

If the header file is only used in the package you can put it in src/.

The .cpp files usually go in src/.

Regarding CMake, in most cases you don't need to put the headers in there. If you create a new package the CMakeLists.txt already contains the commands for creating a library and exectable, you just need to uncomment them.

Can you be more precise on what exactly you are doing, give a minimal example? example and say what doesn't work (i.e. what means "cannot use it" for you)? Are you working in the same package or are you building a library package that you want to use in other packages? In the second case you need to export line in the manifest, but the term "-lros" is the linker directive for this package, i.e. instead of "-lros" it should be "-lmylib".

If class.h and class.cpp are in src/ and you have another source file in src/ you should be able to include and use class.h without a problem. If class.h is in include/mypackage/class.h, you should include that file using #include "mypackage/class.h".

You are naming three totally different things with "putting". A class cannot be used by a service (if you mean a ROS service), you need to provide a service server implementation.

Regarding "putting" in the sense of file location: If other packages besides the one you are implementing are using the class it is good practice to put the header in include/mypackage/header.h, and include the file in your sources via #include "mypackage/header.h". In that case you should also take care of exporting c++ directives in the manifest.

If the header file is only used in the package you can put it in src/.

The .cpp files usually go in src/.

Regarding CMake, in most cases you don't need to put the headers in there. If you create a new package the CMakeLists.txt already contains the commands for creating a library and exectable, you just need to uncomment them.

Can you be more precise on what exactly you are doing, give a minimal example and say what doesn't work (i.e. what means "cannot use it" for you)? Are you working in the same package or are you building a library package that you want to use in other packages? In the second case you need to the export line in the manifest, but the term "-lros" is the linker directive for this package, i.e. instead of "-lros" it should be "-lmylib".

If class.h and class.cpp are in src/ and you have another source file in src/ you should be able to include and use class.h without a problem. If class.h is in include/mypackage/class.h, you should include that file using #include "mypackage/class.h".

You are naming three totally different things with "putting". A class cannot be used by a service (if you mean a ROS service), you need to provide a service server implementation.

Regarding "putting" in the sense of file location: If other packages besides the one you are implementing are using the class it is good practice to put the header in include/mypackage/header.h, and include the file in your sources via #include "mypackage/header.h". In that case you should also take care of exporting c++ directives in the manifest.

If the header file is only used in the package you can put it in src/.

The .cpp files usually go in src/.

Regarding CMake, in most cases you don't need to put the headers in there. If you create a new package the CMakeLists.txt already contains the commands for creating a library and exectable, you just need to uncomment them.

Can you be more precise on what exactly you are doing, give a minimal example and say what doesn't work (i.e. what means "cannot use it" for you)? you, give the error messages)? Are you working in the same package or are you building a library package that you want to use in other packages? In the second case you need the export line in the manifest, but the term "-lros" is the linker directive for this package, i.e. instead of "-lros" it should be "-lmylib".

If class.h and class.cpp are in src/ and you have another source file in src/ you should be able to include and use class.h without a problem. If class.h is in include/mypackage/class.h, you should include that file using #include "mypackage/class.h".