tf2 error when switching from catkin_make to catkin_make_isolated
I'm trying to migrate from using catkin_make to catkin build using this guide, which recommends using catkin_make_isolated as an intermediate step to determine whether the packages are suitable for building in isolation.
I'm getting an issue building one package using catkin_make_isolated, which seems to stem from an issue within the tf2 dependency. I'm a little confused as to why switching causes the issue to appear as the tf2 code hasn't been changed. I'm wondering if there's a flag not being passed to the compiler as a result of the switch, but I'm not entirely sure what I should be looking for. Any help would be much appreciated!
Below is an excerpt of the output from the build showing the errors:
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:329:17: error: The address of local variable 'd' is accessed at non-zero index. [objectIndex]
dst[0] = src[3];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:327:43: note: Address of variable taken here.
unsigned char *src = (unsigned char *)&d;
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:329:17: note: The address of local variable 'd' is accessed at non-zero index.
dst[0] = src[3];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:330:8: error: The address of local variable 'a' is accessed at non-zero index. [objectIndex]
dst[1] = src[2];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:326:43: note: Address of variable taken here.
unsigned char *dst = (unsigned char *)&a;
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:330:8: note: The address of local variable 'a' is accessed at non-zero index.
dst[1] = src[2];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:330:17: error: The address of local variable 'd' is accessed at non-zero index. [objectIndex]
dst[1] = src[2];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:327:43: note: Address of variable taken here.
unsigned char *src = (unsigned char *)&d;
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:330:17: note: The address of local variable 'd' is accessed at non-zero index.
dst[1] = src[2];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:331:8: error: The address of local variable 'a' is accessed at non-zero index. [objectIndex]
dst[2] = src[1];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:326:43: note: Address of variable taken here.
unsigned char *dst = (unsigned char *)&a;
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:331:8: note: The address of local variable 'a' is accessed at non-zero index.
dst[2] = src[1];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:331:17: error: The address of local variable 'd' is accessed at non-zero index. [objectIndex]
dst[2] = src[1];
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:327:43: note: Address of variable taken here.
unsigned char *src = (unsigned char *)&d;
^
/opt/ros/noetic/include/tf2/LinearMath/Scalar.h:331:17: note: The address of local variable 'd' is accessed at non-zero index.
dst[2 ...
I've found that commenting out the following lines in my CMakeLists.txt file prevents the error:
Tried pulling the code for tf2 down and running what I presume is the same command catkin is running under the hood, but was unable to replicate the issue
From what you describe, I don't believe this would be an issue with
catkin_tools
, nor withcatkin_make_isolated
.Tbh, the "migration" tutorial is a bit too conservative.
If packages don't build with
catkin_tools
, it's not really seriously more complex to diagnose that withcatkin_tools
than it is withcatkin_make_isolated
.Often seen problems mostly include build order issues due to people not having stated their
build_depend
s properly in the manifest.A lot of these can be detected by catkin_lint.
Thanks for pointing me in the direction of catkin lint. It seems super handy. I ran it over the culprit package and fixed the errors (missing build_depends as you said) but still getting the tf2 issue when building
If you post your
CMakeLists.txt
we might be able to spot something.Sure thing. I've added it to the end of my original post.
I'm confused now btw: the error message you mention:
is a
cppcheck
error.It's not a compilation error.
what do you mean by this exactly?
This also confuses me:
so you want to run
cppcheck
if testing is disabled?The file wasn't written by me, so not entirely sure why it's its set to run when testing is disabled. I'll have to chat to the author about that! Agree that cppcheck is at the heart of the issue, but I'm a little confused as to why the error only shows up when using catkin build. catkin_make compiles (and presumably checks) the same code just fine. I tried cloning the geometry2 repository and running cpp over the code manually using
but can't reproduce the issue...