Hello,
I have a computer graphics course in java using OpenGL, but I can’t get any code to run, I get this:
+ JARDIR=./jars
+ javac -cp ./jars/gluegen-rt.jar:./jars/jogl-all.jar:./jars/joml-1.10.8.jar Cli.java Main.java MainView.java OpenGLManager.java
+ java -cp ./jars/gluegen-rt.jar:./jars/gluegen-rt-natives-linux-amd64.jar:./jars/gluegen-rt-natives-macosx-universal.jar:./jars/gluegen-rt-natives-windows-amd64.jar:./jars/jogl-all.jar:./jars/jogl-all-natives-linux-amd64.jar:./jars/jogl-all-natives-macosx-universal.jar:./jars/jogl-all-natives-windows-amd64.jar:./jars/joml-1.10.8.jar:. Main
Warning: Caught Exception while retrieving executable temp base directory:
java.io.IOException: Could not determine a temporary executable directory
at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1362)
at com.jogamp.common.util.cache.TempFileCache.<clinit>(TempFileCache.java:84)
at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:96)
at com.jogamp.common.os.Platform$1.run(Platform.java:313)
at com.jogamp.common.util.SecurityUtil.doPrivileged(SecurityUtil.java:80)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:151)
at OpenGLManager.<init>(OpenGLManager.java:37)
at Main.main(Main.java:6)
Exception in thread "main" java.lang.UnsatisfiedLinkError: Couldn't load library 'gluegen_rt' generically including [], nor as [/usr/java/packages/lib/libgluegen_rt.so, /usr/lib64/libgluegen_rt.so, /lib64/libgluegen_rt.so, /lib/libgluegen_rt.so, /usr/lib/libgluegen_rt.so, /home/matteob/Code/uni/ICGV-assignments/assignment2_templates/ex1_1/libgluegen_rt.so, /home/matteob/Code/uni/ICGV-assignments/assignment2_templates/ex1_1/natives/linux-amd64/libgluegen_rt.so]
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:634)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:427)
at com.jogamp.common.os.Platform$1.run(Platform.java:321)
at com.jogamp.common.util.SecurityUtil.doPrivileged(SecurityUtil.java:80)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:151)
at OpenGLManager.<init>(OpenGLManager.java:37)
at Main.main(Main.java:6)
Here’s the flake for the dev shell:
{
description = "";
inputs =
{
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
in
{
devShells.${system}.default =
pkgs.mkShell
{
nativeBuildInputs = with pkgs; [
jdk
jogl
jdt-language-server
libGL
];
shellHook = ''
export NIX_LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath [ pkgs.libGL pkgs.jogl ]}
echo $NIX_LD_LIBRARY_PATH
'';
};
};
}
I added this to my config:
programs.nix-ld.enable = true; # allow for clangd dynamic linked libraries
programs.nix-ld.package = pkgs.nix-ld-rs;
programs.nix-ld.libraries = with pkgs; [ stdenv.cc.cc pkgs.libGL pkgs.jogl];
doesn’t help
I think that the error is because it’s trying to do some dynamic linking with system packages, which isn’t how nix is supposed to work. idealy I’d like to be able to fix this with the dev shell flake, instead of having to make system changes to nix-ld.
after some googling I found that this also uses joml: sweethome3d, but my knowledge of nix ends about here. I guess the answer might lie with pathelf? but I don’t know how it works.