When I ran my catkin_make, I understand that it should automatically copy the header files (in this case mosquitto.h) which I included in the main cpp file into devel/include and create an executable, however, it is not doing so. devel/include doesn't even exist in my catkin_ws. My header file is in catkin_ws/src/package_name/include/package_name
Error:
Linking CXX executable /home/catkin_ws/devel/lib/mqtt_pub/mqtt_pub_node
/usr/bin/ld: cannot find -lmosquitto.h
collect2: error: ld returned 1 exit status
make[2]: *** [/home/catkin_ws/devel/lib/mqtt_pub/mqtt_pub_node] Error 1
make[1]: *** [mqtt_pub/CMakeFiles/mqtt_pub_node.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j1 -l1" failed
Note that mqtt_pub_node doesn't exist. Why is it looking for something that doesn't exist? It should be automatically created. From what I know, the executable should be in devel/lib/mqtt_pub, not sure where did the system think about devel/lib/mqtt_pub/mqtt_pub_node. If I create the devel/lib/mqtt_pub/mqtt_pub_node and put my header file in it, the catkin_make is successful, but the executable would not be created.
CMakeList.txt
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES mqtt_pub
CATKIN_DEPENDS roscpp std_msgs
DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
/catkin_ws/src/mqtt_pub/include/mqtt_pub
include
)
link_directories(
/catkin_ws/src/mqtt_pub/include/mqtt_pub
)
link_libraries(
mosquitto.h
)
add_executable(mqtt_pub_node src/mqtt_publish.cpp)
target_link_libraries(mqtt_pub_node ${catkin_LIBRARIES})
package.xml
catkin roscpp std_msgs roscpp std_msgs
Would appreciate the guidance in solving this issue. I'm really clueless about the error, have research online and my cmake and xml file seems to be alright. Errors in my maincpp file have been rectified. Thanks!
↧