I am trying to write my own plugin, which has its own header file. For its compilation, I am following Plugins 101 tutorials. When I run make command in terminal in build folder, it says "fatal error: myproject.hh: No such file or directory compilation terminated". How to solve this problem ?
Gazebo Version: 7.13.1
Ubuntu 16.04,
Tutorial Link: Plugins 101
File Structure :
Myproject (Folder)
----myproject.cc
----myproject.hh
----CMakeLists.txt
----build (Folder)
CMakeLists.txt:
cmakeminimumrequired(VERSION 2.8 FATALERROR)
findpackage(gazebo REQUIRED)
includedirectories(${GAZEBOINCLUDEDIRS})
linkdirectories(${GAZEBOLIBRARYDIRS})
list(APPEND CMAKECXXFLAGS "${GAZEBOCXXFLAGS}")
add_library(myproject SHARED myproject.cc)
targetlinklibraries(myproject ${GAZEBO_LIBRARIES})
I have written a new header file myproject.hh and included it in myproject.cc. When I try to compile myproject.cc, it says "myproject.hh not found". What changes should I make to my CMakeLists.txt, so that it recognises the header file. Thanks in advance.
Asked by pk on 2018-06-27 03:12:57 UTC
Answers
You need to tell the compiler to use your header file. Try to change:
add_library(myproject SHARED myproject.cc)
to
add_library(myproject SHARED myproject.cc myproject.hh)
if this dont fix your problem you should make sure to include your header file like this: #include "myproject.hh"
and not with these <>.
Asked by wentz on 2018-06-28 03:21:36 UTC
Comments
What difference it makes by using " " instead of <> ?
Asked by pk on 2018-06-28 05:56:52 UTC
In general it should work with both. The difference is that <> are used for including system libraries while "" are used for local libraries. Sometimes this could lead to the compiler can't find the include file. Just give it a try with both ways.
Asked by wentz on 2018-06-30 06:01:57 UTC
I gave it a try with both, "" and <> it didn't work. Thanks a lot for the help ! I added "include_directories(${HEADER_FILES})" to my CMakeLists.txt file and it works.
Asked by pk on 2018-06-30 10:59:21 UTC
Comments
What's the
include
line inmyproject.cc
?Asked by chapulina on 2018-06-27 11:05:23 UTC
cmake looks fine from an amateur pov
Asked by tacyon on 2018-06-28 01:28:55 UTC
include
Asked by pk on 2018-06-28 05:58:16 UTC
I add "include_directories(${HEADER_FILES})" to my CMakeLists.txt file and it works.
Asked by pk on 2018-06-28 06:01:12 UTC