Adding include_directories catkin_INCLUDE_DIRS gives bizarre VTK errors

asked 2022-01-16 22:59:19 -0500

ThreeForElvenKings gravatar image

Hello, I am trying to compile a c++ project (X) as a ros package in my workspace. The c++ project has multiple modules (Y,Z). Here is a generic structure of the project

X
|-src
  |-CMakeLists.txt (2)
  |- Y
     |-CMakeLists.txt (3)
  |- Z
     |-CMakeLists.txt (4)
|-CMakeLists.txt (1)
|-package.xml

I've numbered the CMakeLists here to refer them later. for The C++ project depends on a number of libraries and modules (one of them being vtk8.2). Here is a part my CMakeLists.txt (1)

set(PROJECT_INCLUDE_CONTENT "include(\${VTK_USE_FILE})
# if(VTK_VERSION VERSION_LESS \"8.1\")
#   message(ERROR \"Wrong VTK version! At least 8.1 required!\")
# endif()")

find_package(catkin REQUIRED COMPONENTS
    roscpp
    message_generation
    pcl_ros
    pcl_conversions
    eigen_conversions
    geometry_msgs
    sensor_msgs
    std_msgs
    tf
    tf2_eigen
    )

catkin_package(
    #  INCLUDE_DIRS include
    #  LIBRARIES hello_world
    #  CATKIN_DEPENDS roscpp std_msgs
    #  DEPENDS system_lib
    )

include_directories(
# include
   ${catkin_INCLUDE_DIRS} 
   # src/X
)

### Compile- and install-related commands.
add_subdirectory(src/X)

Now, if I comment out the include_directories part, the entire project code compiles without errors. But in this case, I cannot really write a ROS node, since ros.h is not found. However, if I uncomment the include_directories part, I get vtk errors: ‘class vtkTextProperty’ has no member named ‘FrameOff’ and error: ‘class vtkUnsignedCharArray’ has no member named ‘InsertNextTypedTuple’; did you mean ‘InsertNextTuple’?

I don't really understand why this is happening, as my understanding of catkin is not great. But I'd like to get this working.

Thanks.

edit retag flag offensive close merge delete

Comments

In melodic, the default version is vtk6. Have you installed libvtk8-dev? Where did you get it from, as it's not in the standard ubuntu 18 repositories?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-01-17 08:20:21 -0500 )edit

I built vtk8 from source and installed it. And catkin_make is able to find the vtk version and says that it is 8.2

ThreeForElvenKings gravatar image ThreeForElvenKings  ( 2022-01-17 11:59:04 -0500 )edit

Ah, I see that vtk6 was installed when I installed pcl_ros. I think I understand my issue now. Is there a way I could isntall pcl_ros with vtk8? I think that would solve my issue

ThreeForElvenKings gravatar image ThreeForElvenKings  ( 2022-01-17 12:24:01 -0500 )edit

No. There isn't.

You'd have to build everything and anything that (transitively) links against vtk from source in your own workspace.

Otherwise there is a high chance of ABI incompatibilities, with (in many cases) SEGFAULTs and other hard to diagnose crashes.

gvdhoorn gravatar image gvdhoorn  ( 2022-01-17 12:30:27 -0500 )edit