Hi there.
Recently we started using PCL in our application. Everything worked well on the x86_64 side. Our next step is to cross-compile our application to aarch64 and this is where the problem raised.
A little background of how we do cross-compile. We use Docker to generate the SYSROOT
of the target system, i.e., Ubuntu 18.04 aarch64. In the Dockerfile, we install libpcl-dev
via apt-get
, which has a dependency of vtk-6.3
. Then we extract the /usr
folder and tell CMake to use that folder as SYSROOT
.
The first problem was that PCL has a hard-coded path to vtk6.3 which is in the host filesystem instead of in the SYSTOOT
elseif(NOT VTK_DIR AND NOT ANDROID)
set(VTK_DIR "/usr/lib/cmake/vtk-6.3" CACHE PATH "The directory containing VTKConfig.cmake")
endif(PCL_ALL_IN_ONE_INSTALLER AND NOT ANDROID)
This was solved by adding -DVTK_DIR=${SYSROOT}/usr/lib/cmake/vtk-6.3
. However, we then found that VTK also has some hard-coded path to some libraries:
/usr/lib/aarch64-linux-gnu/libfreetype.so
/usr/lib/aarch64-linux-gnu/libz.so
/usr/lib/aarch64-linux-gnu/libexpat.so
/usr/lib/aarch64-linux-gnu/libtheoraenc.so
/usr/lib/aarch64-linux-gnu/libtheoradec.so
/usr/lib/aarch64-linux-gnu/libogg.so
...
Take libfreetype.so
as an example, it was added by Modules/vtkfreetype.cmake
set(vtkfreetype_LIBRARIES "/usr/lib/aarch64-linux-gnu/libfreetype.so")
set(vtkfreetype_INCLUDE_DIRS "${VTK_INSTALL_PREFIX}/include/vtk-6.3;/usr/include/freetype2")
So clearly this is a path to the host, not to the SYSROOT
. Therefore, our cross compile failed because the path /usr/lib/aarch64-linux-gnu/libfreetype.so
doesn’t exist on the x86_64 machine and it’s not a target either.
I feel it’ll be rude to ask VTK developers to stop using hardcoded when they releasing vtk
pkg to Ubuntu sources. Is there any better way to solve the problem?
Thanks.