Search code examples
springspring-bootspring-data-jpagraalvm-native-image

Running spring boot native application getting the following error


While running a spring boot 3 native application on bellsoft-liberica-vm-core-openjdk17-22.3.0 I'm getting this following error after creating the image.

./target/blog: error while loading shared libraries: libfreetype.so: cannot open shared object file: No such file or directory

mvn -Pnative native:compile to create the image.

./target/blog to start the image.


Solution

  • Might be a bit late, but I recently faced the same problem (using Ubuntu 22.04).

    apt-get install libfreetype-dev will install the required library.


    Or you might create a symlink to point to another installed version, as described here: https://stackoverflow.com/a/34257466

    (libfreetype6 may already be installed, otherwise it may be via apt-get install libfreetype6).

    1. find the location of the installed library:
    $ dpkg -L libfreetype6
    /usr/lib/x86_64-linux-gnu/libfreetype.so.6
    
    1. create a symlink:
    $ ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so.6 ~/tmp/lib/libfreetype.so
    
    1. provide the symlink when running the native-image:
    $ LD_LIBRARY_PATH=~/tmp/lib ./build/native/nativeCompile/myAppNativeImage