Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to include headers found in devel/include, generated by grpc #31

Open
9a3eedi opened this issue Jun 12, 2018 · 11 comments
Open

Unable to include headers found in devel/include, generated by grpc #31

9a3eedi opened this issue Jun 12, 2018 · 11 comments
Assignees
Labels

Comments

@9a3eedi
Copy link

9a3eedi commented Jun 12, 2018

I have a project (let's call it parrot_common_wrapper) that uses grpc to generate headers from protobuf. protobufs are found in parrot_common_wrapper/parrot-common/tctm/, and an example of a protobuf is Echo.pb. These headers are then installed into devel/include in the root directory, no further subdirectories. I can see this myself.

I have another project (let's call it parrot_comm) in which I would like to include these generated headers, but for the life of me I couldn't get it to work. It simply could not find the requested header file. I have tried the following to include it:

#include "Echo.pb.h"
#include "tctm/Echo.pb.h"
#include "parrot_common/tctm/Echo.pb.h"
#include "parrot_common_wrapper/Echo.pb.h" 
#include "parrot_common_wrapper/parrot-common/tctm/Echo.pb.h"

But none of these work, all giving me the same error: that the file is not found

Here is my CMakeLists for parrot_comm:

cmake_minimum_required(VERSION 2.8.3)
project(parrot_comm)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  grpc
  std_msgs
  parrot_common_wrapper
)

catkin_package(
	#  INCLUDE_DIRS include
	# LIBRARIES parrot_common_wrapper ${ALL_PROTOBUF_LIBS}
  CATKIN_DEPENDS roscpp std_msgs parrot_common_wrapper
#  DEPENDS system_lib
)

include_directories(
	#include
  ${catkin_INCLUDE_DIRS}
)

add_executable(parrot_comm src/parrot_comm.cpp)

target_link_libraries(parrot_comm ${catkin_LIBRARIES} parrot_common_wrapper)

And here is the CMakeLists for the parrot_common_wrapper project

cmake_minimum_required(VERSION 2.8.3)
project(parrot_common_wrapper)

find_package(catkin REQUIRED COMPONENTS
  grpc
  roscpp
)

catkin_package(
#  INCLUDE_DIRS include
 LIBRARIES parrot_common_wrapper
#  CATKIN_DEPENDS grpc roscpp
#  DEPENDS system_lib
)

set(TCTM_DIR ./parrot-common/tctm)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

generate_proto(parrot_common_wrapper SRC_BASE ${TCTM_DIR} FILES 
	${TCTM_DIR}/Subsystem.proto
	${TCTM_DIR}/Echo.proto
	${TCTM_DIR}/Telemetry.proto
	${TCTM_DIR}/Telecommand.proto
)


What am I missing? I'm sorry if this is a very trivial problem, I've been dragging my hair out for a whole day trying to fix this.

@BillWSY
Copy link
Member

BillWSY commented Jun 12, 2018

I was not able to reproduce the problem (using some of my catkin_grpc_examples packages). In theory, #include "Echo.pb.h" should work. Can you confirm in package.xml, parrot_comm build_depend on parrot_common_wrapper?

Also, if you can provide a minimal example to reproduce this issue (preferable a GitHub repository), I am happy to take a look into.

(I removed my previous comments because I missed some details in your issues -- sorry)

@BillWSY
Copy link
Member

BillWSY commented Jun 12, 2018

Also, some other mistakes in your CMakeLists.txt

parrot_common_wrapper:

catkin_package(
 LIBRARIES parrot_common_wrapper ${ALL_PROTOBUF_LIBS}
 CATKIN_DEPENDS grpc
)

parrot_comm:

target_link_libraries(parrot_comm ${catkin_LIBRARIES})

@9a3eedi
Copy link
Author

9a3eedi commented Jun 13, 2018

I fixed the mistakes you mentioned and also confrmed that parrot_comm's package.xml has a build_depend on parrot_common_wrapper. However I'm still facing the same problem.

I've attached a minimum example. Just extract this into a freshly made catkin workspace. I tried to recreate the same folder structure I am using now, in case it is relevant. The "protobuf_package" contains the protobufs and is equivalent to the "parrot_common_wrapper" package I'm using, and the "linked_package" is trying to use the header built from the protobuf_package, i.e. equivalent to "parrot_comm" in my case. I am facing the exact same issue with this example.

grpc_header_bug_testcase.zip

@BillWSY
Copy link
Member

BillWSY commented Jun 13, 2018

Strangely, these packages built without any issue on my computer. Can you also report your catkin version? Did you use catkin build or catkin_make? Are you running catkin is isolated mode?

@9a3eedi
Copy link
Author

9a3eedi commented Jun 18, 2018

That is very strange. I have used catkin_make. No isolated mode or anything. I do not have catkin-tools installed, so I haven't tried using catkin build.

As this seems to be an issue related to my environment, I also put this question in ROS Answers. It can be found here. https://answers.ros.org/question/294331/unable-to-include-headers-found-in-develinclude-generated-by-grpc/ . But I would appreciates any insights in the meantime.

I'm running ROS Kinetic under Ubuntu MATE, with ros-kinetic-catkin 0.7.11-0xenial-20180222-175501-0800 amd64 installed

@9a3eedi
Copy link
Author

9a3eedi commented Jun 18, 2018

Another note: I have tried the test case on a completely different machine (a raspberry pi running a fresh install of Ubuntu MATE 16.04 and Kinetic), and I'm facing the same problem.

@BillWSY
Copy link
Member

BillWSY commented Jun 18, 2018

Thanks for the information. I was using catkin-tools. I will test with catkin_make and try to debug.
Meanwhile, is there any chance that you can use catkin-tools to test if the problem persists?

@BillWSY
Copy link
Member

BillWSY commented Jun 18, 2018

I can confirm the bug with catkin_make. I will try to dig into it when I have time.

@BillWSY BillWSY self-assigned this Jun 18, 2018
@BillWSY BillWSY added the bug label Jun 18, 2018
@BillWSY
Copy link
Member

BillWSY commented Jun 18, 2018

Temporary workaround:
Include the following lines in linked_package/CMakeLists.txt

include_directories(${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION})

@9a3eedi
Copy link
Author

9a3eedi commented Jun 18, 2018

Workaround works for me. Thanks! Will use this for now.

As for catkin-tools, I'm actually unfamiliar with using them so it'll take me a while to try...

@BillWSY
Copy link
Member

BillWSY commented Jun 18, 2018

It seems ROS's message generation adds the include directory in their CMakeList rules.
https://github.com/ros/gencpp/blob/b41ee3060badd660662e21cd9d4f81971c87a420/cmake/gencpp-extras.cmake.em#L69

Maybe we should also do that in the CMakeLists.txt in grpc package. When a user find that package, it would prepend the global include directory to the lookup list. Or we can ask user to put this directory into catkin_packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants