syntax error near unexpected token `('
`int main(int argc, char **argv)'
when i build the entire workspace it run well as i think but there are some warnings appears
also gives me this two lines when i run the node
/home/moustafa/catkin_ws/src/hamo/src/demo_topic_publisher.cpp: line 5: syntax error near unexpected token `('
/home/moustafa/catkin_ws/src/hamo/src/demo_topic_publisher.cpp: line 5: `int main(int argc, char **argv)'
build output:
Base path: /home/moustafa/catkin_ws
Source space: /home/moustafa/catkin_ws/src
Build space: /home/moustafa/catkin_ws/build
Devel space: /home/moustafa/catkin_ws/devel
Install space: /home/moustafa/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/moustafa/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/moustafa/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/moustafa/rover_ws/devel;/home/moustafa/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/moustafa/rover_ws/devel;/home/moustafa/catkin_ws/devel;/opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/moustafa/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.1
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 1 packages in topological order:
-- ~~ - hamo
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'hamo'
-- ==> add_subdirectory(hamo)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Configuring done
CMake Warning (dev) at hamo/CMakeLists.txt:200 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
The dependency target "mastering_ros_demo_pkg_generate_messeges_cpp" of
target "demo_topic_subscriber" does not exist.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at hamo/CMakeLists.txt:199 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
The dependency target "mastering_ros_demo_pkg_generate_messeges_cpp" of
target "demo_topic_publisher" does not exist.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /home/moustafa/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/moustafa/catkin_ws/build"
####
[ 50%] Built target demo_topic_subscriber
[100%] Built target demo_topic_publisher
Thanks
What command are you using to "run the node"? It looks to me like maybe your file
demo_topic_publisher.cpp
is executable, and you are trying to execute the source code file instead of the executable built by catkin. What are the permissions of the cpp file?The permissions: i checked allow executing file as program, I'm using
rosrun hamo demo_topic_publisher.cpp
to run executable file after i modified package.xml and CMakeLists.txt NOTE: i'm following Mastering_ROS_for_Robotics_Programming book commandsThat is exactly as I suspected. I'm going to write an answer explaining in more detail.