# Custom services header file is not found

**URL:** <https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816>\
**Category:** ROS Basics In 5 Days (C++)\
**Created:** [May 28, 2020, 11:38pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816 "2020-05-28T23:38:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [May 28, 2020, 11:38pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/1 "2020-05-28T23:38:35Z")

</div>

I am experiencing an issue exactly like the one found [here](https://get-help.robotigniteacademy.com/t/had-to-rebuild-services-header-files-after-every-session/1752), but maybe I can re-explain the steps that led me to the issue. Every package in my workspace can no longer can find header files for any of my custom service messages.

I was able to compile and run my packages, I logged off and when I came back I encountered this error:  
/home/user/catkin\_ws/src/my\_cpp\_class/src/bb8\_move\_duration\_srv\_class.cpp:2:42: fatal error: my\_cpp\_class/durationservice.h: No such file or directory

The package that is causing error was not a package I was working on at the time. If I delete this package and try catkin make, then the next package with custom service messages raises this same error.

Now, if I do the following then everything works:

- comment out the add executable lines in my makefile
- compile the package
- source devel/setup.bash
- uncomment the add executable lines
- recompile

What is puzzling to me is that all of these packages (makefiles, launch, executables, etc.) were not edited and working before encountering this error.

---

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [May 28, 2020, 11:44pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/2 "2020-05-28T23:44:39Z")

</div>

I fixed this issue by going to another course and then returning.

---

<div class="post-metadata">

**Author:** ![simon.steinmann91](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/simon.steinmann91/32/324_2.png) [@simon.steinmann91](https://get-help.theconstruct.ai/u/simon.steinmann91)\
**Post date:** [May 29, 2020, 9:43am UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/3 "2020-05-29T09:43:50Z")

</div>

@rmmilner sounds like a sourcing issue. Just running  
`source devel/setup.bash`  
Should fix it. When switching chapter and returning, this is done automatically. @bayodesegun Perhaps you should check that the sourcing is done when reloading a session.

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [May 29, 2020, 12:02pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/4 "2020-05-29T12:02:27Z")

</div>

Strange error here. It could be that your files for the course were not fully loaded at the time the error was happening.

Anyways, should it happen again, please let us know.

---

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [June 4, 2020, 9:29pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/5 "2020-06-04T21:29:39Z")

</div>

@simon.steinmann91 I tried sourcing and it would not fix the issue.

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [June 5, 2020, 11:18am UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/6 "2020-06-05T11:18:00Z")

</div>

Hi @rmmilner is this issue coming up again?

---

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [June 16, 2020, 8:55pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/7 "2020-06-16T20:55:17Z")

</div>

@bayodesegun

Yes this exact issue has happened again. I created a new package, did catkin\_make and now some old package from the first unit can’t find the header-file for my custom service message. This package I haven’t touched for a long while.

However, this time, leaving the module and returning did not fix the issue. I had to comment the executable lines, make, source, uncomment lines, and make again to have it compile correctly.

**I have discovered that letting the module ‘time-out’ is what causes this.** When I leave the window open for too long and it disconnects, this is when it happens. Leaving the module normally does not cause the error.

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [June 17, 2020, 9:51am UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/8 "2020-06-17T09:51:33Z")

</div>

Hi @rmmilner,

Sorry for the trouble. We’ll have a look at the timeout process.

In the meantime, should it happen again, can you try, in the `catkin_ws` directory:

```auto
# refresh the build and devel folders
rm -rf build/ devel/
catkin_make
source devel/setup.bash

```

---

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [June 17, 2020, 9:25pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/9 "2020-06-17T21:25:55Z")

</div>

> [@bayodesegun](#):
>
> ```auto
> rm -rf build/ devel/
> catkin_make
> source devel/setup.bash
> 
> ```

I tried this and I couldn’t get past the make step, same error.

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [June 18, 2020, 7:24am UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/10 "2020-06-18T07:24:37Z")

</div>

Please post the exact error you are seeing now. It might be another reason or just that your CMakeLists.txt and/or pacakage.xml is/are not properly setup.

---

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [June 18, 2020, 6:44pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/11 "2020-06-18T18:44:18Z")

</div>

![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/7/7b97ba24a4720061353970a34df27cb26744e626.png)

 ![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/1/1b3827b526d9a2da537d292877fafc86217edcbd.png)

 ![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/5/537cb868b968c2ddd8d3cbc55dd3a177cdc82216.png)

@bayodesegun

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [June 19, 2020, 9:16am UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/12 "2020-06-19T09:16:16Z")

</div>

@rmmilner

You are trying to import a message from another package `my_cpp_class`. Please take note of the following:

1. To do this, you needed to have added `my_cpp_class` as a dependency when creating the package, i.e. `catkin_create_pkg your_package_name roscpp my_cpp_class other_dependencies`.
2. For the Services Quiz (and other quizzes), you should create the custom message within the quiz package itself rather than import it from another package. Yeah, we know about code reuse but just want to keep things simple for the automatic grader. Also, you get to practise creating a custom message again 😉.

Please adjust your package and let us know how it goes.

---

<div class="post-metadata">

**Author:** ![rmmilner](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rmmilner/32/10_2.png) [@rmmilner](https://get-help.theconstruct.ai/u/rmmilner)\
**Post date:** [June 23, 2020, 5:43pm UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/13 "2020-06-23T17:43:57Z")

</div>

> [@bayodesegun](#):
>

Maybe I am misunderstanding but the service was created in the package that I am using it in.

 ![image](https://get-help.theconstruct.ai/uploads/default/original/2X/2/2e1399bfd52869b0bb23792372d6986c47399e74.png)

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [June 24, 2020, 10:26am UTC](https://get-help.theconstruct.ai/t/custom-services-header-file-is-not-found/3816/14 "2020-06-24T10:26:47Z")

</div>

Oh, I see.

Did you follow the guide for preparing `CMakeLists.txt` and `package.xml`? From the `CMakeLists.txt` you shared, I can see the following are missing:

- `std_msgs` is missing in `find_package`. And do you really need `geometry_msgs` for building your custom message?
- `catkin_package` is empty? Why?
- Did you edit `package.xml` as indicated?

I suggest that you carefully review the section about creating custom service messages in the notebook (section titled _How to Prepare CMakeLists.txt and package.xml for Custom Service Compilation_ in Unit **Understanding ROS Services - Server** ), carefully make needed changes and then let us know if you still have problems.

**PS** : before compiling again, don’t forget to `rm -rf build/ devel/`.
