Adding include_directories catkin_INCLUDE_DIRS gives bizarre VTK errors
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.
Asked by ThreeForElvenKings on 2022-01-16 23:59:19 UTC
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?
Asked by Mike Scheutzow on 2022-01-17 09:20:21 UTC
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
Asked by ThreeForElvenKings on 2022-01-17 12:59:04 UTC
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
Asked by ThreeForElvenKings on 2022-01-17 13:24:01 UTC
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)
SEGFAULT
s and other hard to diagnose crashes.Asked by gvdhoorn on 2022-01-17 13:30:27 UTC