# VTK uses hard-coded path to freetype.so resulting in failure of cross-compiling

**URL:** https://discourse.vtk.org/t/vtk-uses-hard-coded-path-to-freetype-so-resulting-in-failure-of-cross-compiling/4377
**Category:** Support
**Created:** [October 7, 2020, 7:06pm UTC](https://discourse.vtk.org/t/vtk-uses-hard-coded-path-to-freetype-so-resulting-in-failure-of-cross-compiling/4377 "2020-10-07T19:06:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![left4taco](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/bcef8e/32.png) [@left4taco](https://discourse.vtk.org/u/left4taco)
#### Post date: [October 7, 2020, 7:06pm UTC](https://discourse.vtk.org/t/vtk-uses-hard-coded-path-to-freetype-so-resulting-in-failure-of-cross-compiling/4377/1 "2020-10-07T19:06:43Z")

</div>

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`

```auto
  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:

```auto
/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`

```auto
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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 8, 2020, 1:59pm UTC](https://discourse.vtk.org/t/vtk-uses-hard-coded-path-to-freetype-so-resulting-in-failure-of-cross-compiling/4377/2 "2020-10-08T13:59:19Z")

</div>

6.3 is very old. 9.0 should no longer have any hard-coded paths (it was something I kept in mind when reworking the build system 2 years ago). 8.2 probably still has hard-coded paths though.
