Executable not found calling rosrun

Hello ROS Developers!

I don’t know if this is the correct way to do this, but I would like to leave this issue if someone encounters this problem.

I have seen several students having problems when executing some nodes programmed in C++.

rosrun <package> <name_script> 

And the terminal prompts with an error saying that the program doesn’t exist.

I did have this issue because I am a bit headstrong, and wanted to create my own .cpp files.
I have to say sorry because you are told to use and modify the example scripts that are already created on the package, but, as I said, I didn’t want to remove those in case I wanted to check them.

But if you check the command used to run the node, you are indeed using a compiled script. But where is it??

I know this is C++ For Robotics and not ROS (C++), but I think is good to point this out.

If you check the CMakeLists of the package, you will see that there are some lines similar to this:

set(csname unit1_exercise)
add_executable(${csname} src/${csname}.cpp)
add_dependencies(${csname} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${csname} ${catkin_LIBRARIES})

This is how your cpp is compiled, and when you source your workspace, you will be able to find the compiled script that is executed.

In case you want to know where the executable is, I can give you a hint…check your devel :wink:

That’s all, in case the developers team sees this topic as not needed or not good for the community.

Bests,
Ángel

Hi @ACTISA,

thank you very much for your willingness to help, in explaining possible reasons why the executable is not found.

In addition to what you said, sometimes the executable is not found also because the person may need to source the workspace, something like this:

cd ~/catkin_ws

source devel/setup.bash

Of course, if it is a custom executable, the workspace needs to be compiled first:

cd ~/catkin_ws

catkin_make

source devel/setup.bash

Once again, thanks for your post.

1 Like