gluonhq / gluon-samples

Gluon sample projects
298 stars 166 forks source link

GlibC error when adaptig HelloPi example with JavaFx 3d #126

Closed geoaxis closed 3 years ago

geoaxis commented 3 years ago

I Managed to compile jar file and native image for HelloPi after adapting the code . The jar file runs fine , but HelloPi native throws the following

./HelloPi: /lib/aarch64-linux-gnu/libc.so.6: version 'GLIBC_2.32' not found (required by ./HelloPi)

Here is the example (running on java https://photos.app.goo.gl/1vVxxEBfE3ZefmsW6)

package hellopi;

import javafx.animation.*;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.transform.*;
import javafx.stage.Stage;
import javafx.util.Duration;

public class HelloPi extends Application {

private Parent createContent() throws Exception {
        Sphere sphere = new Sphere(2.5);
        sphere.setMaterial(new PhongMaterial(Color.FORESTGREEN));

        sphere.setTranslateZ(7);
        sphere.setTranslateX(2);

        Box box = new Box(5, 5, 5);
        box.setMaterial(new PhongMaterial(Color.RED));

        Translate pivot = new Translate();
        Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);

        Rotate xRotate = new Rotate(10, Rotate.Z_AXIS);

        // Create and position camera
        PerspectiveCamera camera = new PerspectiveCamera(true);
        camera.getTransforms().addAll (
                pivot,
                yRotate,
                xRotate,
                new Rotate(-20, Rotate.X_AXIS),
                new Translate(0, 0, -50)
        );

        // animate the camera position.
        Timeline timeline = new Timeline(
                new KeyFrame(
                        Duration.seconds(0), 
                        new KeyValue(yRotate.angleProperty(), 0),
                        new KeyValue(xRotate.angleProperty(), 0) 
                ),
                new KeyFrame(
                        Duration.seconds(15), 
                        new KeyValue(yRotate.angleProperty(), 360),
                        new KeyValue(xRotate.angleProperty(), 360)
                )
        );
        timeline.setCycleCount(Timeline.INDEFINITE);
        timeline.play();

        // Build the Scene Graph
        Group root = new Group();       
        root.getChildren().add(camera);
        root.getChildren().add(box);
        root.getChildren().add(sphere);

        // set the pivot for the camera position animation base upon mouse clicks on objects
        root.getChildren().stream()
                .filter(node -> !(node instanceof Camera))
                .forEach(node ->
                        node.setOnMouseClicked(event -> {
                            pivot.setX(node.getTranslateX());
                            pivot.setY(node.getTranslateY());
                            pivot.setZ(node.getTranslateZ());
                        })
                );

        // Use a SubScene
        SubScene subScene = new SubScene(
                root,
                800,480,
                true,
                SceneAntialiasing.BALANCED
        );
        subScene.setFill(Color.ALICEBLUE);
        subScene.setCamera(camera);
        Group group = new Group();
        group.getChildren().add(subScene);

        return group;
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setResizable(false);
        Scene scene = new Scene(createContent());
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}

More diagnostic data (ldd, ldd version, distribution and unme)

root@raspberrypi:/home/pi/aarch64/bin# ldd HelloPi 
./HelloPi: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./HelloPi)
    linux-vdso.so.1 (0x0000007fa8397000)
    libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007fa4695000)
    libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007fa4681000)
    libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007fa44f6000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fa44c7000)
    libGL.so.1 => /lib/aarch64-linux-gnu/libGL.so.1 (0x0000007fa43d1000)
    libX11.so.6 => /lib/aarch64-linux-gnu/libX11.so.6 (0x0000007fa4286000)
    libgtk-3.so.0 => /lib/aarch64-linux-gnu/libgtk-3.so.0 (0x0000007fa3b5c000)
    libgdk-3.so.0 => /lib/aarch64-linux-gnu/libgdk-3.so.0 (0x0000007fa3a50000)
    libpango-1.0.so.0 => /lib/aarch64-linux-gnu/libpango-1.0.so.0 (0x0000007fa39f7000)
    libcairo.so.2 => /lib/aarch64-linux-gnu/libcairo.so.2 (0x0000007fa38d8000)
    libgdk_pixbuf-2.0.so.0 => /lib/aarch64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x0000007fa38a3000)
    libgio-2.0.so.0 => /lib/aarch64-linux-gnu/libgio-2.0.so.0 (0x0000007fa36c4000)
    libgobject-2.0.so.0 => /lib/aarch64-linux-gnu/libgobject-2.0.so.0 (0x0000007fa365d000)
    libglib-2.0.so.0 => /lib/aarch64-linux-gnu/libglib-2.0.so.0 (0x0000007fa352b000)
    libfreetype.so.6 => /lib/aarch64-linux-gnu/libfreetype.so.6 (0x0000007fa346c000)
    libpangoft2-1.0.so.0 => /lib/aarch64-linux-gnu/libpangoft2-1.0.so.0 (0x0000007fa3446000)
    libgthread-2.0.so.0 => /lib/aarch64-linux-gnu/libgthread-2.0.so.0 (0x0000007fa3434000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fa3377000)
    libEGL.so.1 => /lib/aarch64-linux-gnu/libEGL.so.1 (0x0000007fa3353000)
    libdrm.so.2 => /lib/aarch64-linux-gnu/libdrm.so.2 (0x0000007fa3331000)
    libgbm.so.1 => /lib/aarch64-linux-gnu/libgbm.so.1 (0x0000007fa3312000)
    libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007fa32ee000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fa317c000)
    /lib/ld-linux-aarch64.so.1 (0x0000007fa8369000)
    libGLdispatch.so.0 => /lib/aarch64-linux-gnu/libGLdispatch.so.0 (0x0000007fa2ff1000)
    libGLX.so.0 => /lib/aarch64-linux-gnu/libGLX.so.0 (0x0000007fa2faf000)
    libxcb.so.1 => /lib/aarch64-linux-gnu/libxcb.so.1 (0x0000007fa2f78000)
    libgmodule-2.0.so.0 => /lib/aarch64-linux-gnu/libgmodule-2.0.so.0 (0x0000007fa2f64000)
    libpangocairo-1.0.so.0 => /lib/aarch64-linux-gnu/libpangocairo-1.0.so.0 (0x0000007fa2f46000)
    libXi.so.6 => /lib/aarch64-linux-gnu/libXi.so.6 (0x0000007fa2f27000)
    libXcomposite.so.1 => /lib/aarch64-linux-gnu/libXcomposite.so.1 (0x0000007fa2f14000)
    libXdamage.so.1 => /lib/aarch64-linux-gnu/libXdamage.so.1 (0x0000007fa2f01000)
    libXfixes.so.3 => /lib/aarch64-linux-gnu/libXfixes.so.3 (0x0000007fa2eeb000)
    libcairo-gobject.so.2 => /lib/aarch64-linux-gnu/libcairo-gobject.so.2 (0x0000007fa2ed2000)
    libatk-1.0.so.0 => /lib/aarch64-linux-gnu/libatk-1.0.so.0 (0x0000007fa2e99000)
    libatk-bridge-2.0.so.0 => /lib/aarch64-linux-gnu/libatk-bridge-2.0.so.0 (0x0000007fa2e56000)
    libxkbcommon.so.0 => /lib/aarch64-linux-gnu/libxkbcommon.so.0 (0x0000007fa2e07000)
    libwayland-cursor.so.0 => /lib/aarch64-linux-gnu/libwayland-cursor.so.0 (0x0000007fa2ded000)
    libwayland-egl.so.1 => /lib/aarch64-linux-gnu/libwayland-egl.so.1 (0x0000007fa2ddb000)
    libwayland-client.so.0 => /lib/aarch64-linux-gnu/libwayland-client.so.0 (0x0000007fa2dbc000)
    libepoxy.so.0 => /lib/aarch64-linux-gnu/libepoxy.so.0 (0x0000007fa2c6c000)
    libharfbuzz.so.0 => /lib/aarch64-linux-gnu/libharfbuzz.so.0 (0x0000007fa2b6e000)
    libfontconfig.so.1 => /lib/aarch64-linux-gnu/libfontconfig.so.1 (0x0000007fa2b19000)
    libXinerama.so.1 => /lib/aarch64-linux-gnu/libXinerama.so.1 (0x0000007fa2b04000)
    libXrandr.so.2 => /lib/aarch64-linux-gnu/libXrandr.so.2 (0x0000007fa2aea000)
    libXcursor.so.1 => /lib/aarch64-linux-gnu/libXcursor.so.1 (0x0000007fa2acf000)
    libXext.so.6 => /lib/aarch64-linux-gnu/libXext.so.6 (0x0000007fa2aaf000)
    librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007fa2a97000)
    libthai.so.0 => /lib/aarch64-linux-gnu/libthai.so.0 (0x0000007fa2a7c000)
    libfribidi.so.0 => /lib/aarch64-linux-gnu/libfribidi.so.0 (0x0000007fa2a51000)
    libpixman-1.so.0 => /lib/aarch64-linux-gnu/libpixman-1.so.0 (0x0000007fa29e1000)
    libpng16.so.16 => /lib/aarch64-linux-gnu/libpng16.so.16 (0x0000007fa299c000)
    libxcb-shm.so.0 => /lib/aarch64-linux-gnu/libxcb-shm.so.0 (0x0000007fa2988000)
    libxcb-render.so.0 => /lib/aarch64-linux-gnu/libxcb-render.so.0 (0x0000007fa296b000)
    libXrender.so.1 => /lib/aarch64-linux-gnu/libXrender.so.1 (0x0000007fa2950000)
    libmount.so.1 => /lib/aarch64-linux-gnu/libmount.so.1 (0x0000007fa28e0000)
    libselinux.so.1 => /lib/aarch64-linux-gnu/libselinux.so.1 (0x0000007fa28ac000)
    libresolv.so.2 => /lib/aarch64-linux-gnu/libresolv.so.2 (0x0000007fa2886000)
    libffi.so.6 => /lib/aarch64-linux-gnu/libffi.so.6 (0x0000007fa286e000)
    libpcre.so.3 => /lib/aarch64-linux-gnu/libpcre.so.3 (0x0000007fa27f9000)
    libwayland-server.so.0 => /lib/aarch64-linux-gnu/libwayland-server.so.0 (0x0000007fa27d6000)
    libexpat.so.1 => /lib/aarch64-linux-gnu/libexpat.so.1 (0x0000007fa2797000)
    libXau.so.6 => /lib/aarch64-linux-gnu/libXau.so.6 (0x0000007fa2784000)
    libXdmcp.so.6 => /lib/aarch64-linux-gnu/libXdmcp.so.6 (0x0000007fa276e000)
    libdbus-1.so.3 => /lib/aarch64-linux-gnu/libdbus-1.so.3 (0x0000007fa2709000)
    libatspi.so.0 => /lib/aarch64-linux-gnu/libatspi.so.0 (0x0000007fa26c6000)
    libgraphite2.so.3 => /lib/aarch64-linux-gnu/libgraphite2.so.3 (0x0000007fa2693000)
    libuuid.so.1 => /lib/aarch64-linux-gnu/libuuid.so.1 (0x0000007fa267b000)
    libdatrie.so.1 => /lib/aarch64-linux-gnu/libdatrie.so.1 (0x0000007fa2661000)
    libblkid.so.1 => /lib/aarch64-linux-gnu/libblkid.so.1 (0x0000007fa25fc000)
    libbsd.so.0 => /lib/aarch64-linux-gnu/libbsd.so.0 (0x0000007fa25d6000)
    libsystemd.so.0 => /lib/aarch64-linux-gnu/libsystemd.so.0 (0x0000007fa2529000)
    liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000007fa24f2000)
    liblz4.so.1 => /lib/aarch64-linux-gnu/liblz4.so.1 (0x0000007fa24c7000)
    libgcrypt.so.20 => /lib/aarch64-linux-gnu/libgcrypt.so.20 (0x0000007fa23fa000)
    libgpg-error.so.0 => /lib/aarch64-linux-gnu/libgpg-error.so.0 (0x0000007fa23ca000)
root@raspberrypi:/home/pi/aarch64/bin# ldd --version
ldd (Debian GLIBC 2.28-10+rpt2+rpi1) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
root@raspberrypi:/home/pi/aarch64/bin# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@raspberrypi:/home/pi/aarch64/bin# uname -a
Linux raspberrypi 5.10.60-v8+ #1449 SMP PREEMPT Wed Aug 25 15:01:33 BST 2021 aarch64 GNU/Linux
jperedadnr commented 3 years ago

The GLIBC_XXX issue comes from the fact that you are compiling and linking the native image from a host (i.e. Ubuntu 21) with a newer compiler version (2.32) than the one found on your Raspberry Pi (2.28). There is no easy workaround for this. One possible fix is installing Ubuntu on your Pi, and another, building your app from an older version of Ubuntu (this could be done from GitHub actions for instance)

geoaxis commented 3 years ago

Thank you. I managed to compile correct binary by using chroot on ubuntu (and using ubuntu 18.04 as chroot, based on instructions at https://help.ubuntu.com/community/BasicChroot). After that the sample builds correctly inside the chroot locally and runs on pi like a breeze. Will close the bug.