# Revision history [back]

This errors is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are magic numbers at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.

This errors error is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are magic numbers at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.

This error is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are magic numbers at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.

This error is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are magic numbers at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.

This error is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are magic numbers at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.

This error is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are magic numbers [magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)) at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.

This error is almost certainly caused by trying to "execute" a CPP file instead of executing the binary that is produced by catkin when you build your workspace. Remove the ".cpp" extension from your rosrun command, and be sure that the last argument to rosrun is the name of the executable that was specified in your CMakeLists.txt. For example, let's say your CMakeLists.txt has the following line:

add_executable(demo_topic_publisher src/demo_topic_publisher.cpp)


Then when you build the workspace, you produce an executable binary that is called demo_topic_publisher and to run that binary, the command would be

rosrun hamo demo_topic_publisher


(without the .cpp extension). If your CMakeLists.txt had a different name for the executable (the first argument), then you'd need a different command.

More details:

In Linux if the file permissions of a particular file are set such that you have execute permissions, then this script can be "executed". When you try and execute it a number of different things can happen depending on what type of file you are trying to execute. In your case, you are trying to execute a .cpp file that really shouldn't have executable permissions, nor is it intended to be executed. If you had a hashbang [hashbang](https://en.wikipedia.org/wiki/Shebang_(Unix%29) on the first line, the CPP file would be passed to an interpreter specified on the first line. If you don't have a hashbang, then the, likely, your system is falling back to using sh as the interpreter. Since your CPP code is not valid sh code you get errors.

If you correctly execute the binary that is compiled by catkin (as described above), then there are [magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)) numbers](https://en.wikipedia.org/wiki/Magic_number_(programming%29) at the top of the file that tells the system how it should handle the running of the program. This post on Unix&Linux Overflow has a nice detailed description of how programs get run on Linux.