Tuesday, 12 July 2011

ROS pcl_ros fails to compile with GCC 4.6

Error:
/usr/local/opt/ros/perception_pcl/pcl/include/pcl/ros/conversions.h:284:9: error: taking address of temporary [-fpermissive]

Code fix:
First assign the temporary variable to a local variable. Then reference the address of the local variable. However, this is more complicated with arrays being copied with memcpy. One way is to use a for-loop to replace memcpy.
See patch for a similar error in another library.

Since the change is somewhat drastic, I compiled pcl_ros with gcc-4.5 instead.

# install gcc-4.5
yaourt -S gcc45

Edit perception_pcl/pcl_ros/CMakeLists.txt.
Add the following lines (prefixed with +) near the top, *after* the rosbuild directives.

rosbuild_init()
...

+set (CMAKE_C_COMPILER gcc-4.5)
+set (CMAKE_CXX_COMPILER g++-4.5)

(If the compilers are set before the rosbuild directives, cmake will enter an infinite loop during configuration!)

Then pcl_ros should compile.

No comments:

Post a Comment