I want to use a program that builds jni artifacts and then a java lib that links to the jni artifacts how to i give java the ability to link to those libs?
how does the program reference the libraries? Most of the time there is some java property that can be set to point to the required libs, but this varies from program to program. But the basic recipe would be: nix the jni libs, then use makeWrapper to add -Dmy.prop=/path/to/built/libs.
EDIT: apparently LD_LIBRARY_PATH is searched, so you just need to make sure your program has a runtime dependency on the dll and it should just work?
seting the LD_LIBRARY_PATH would work well the only hiccup is that it uses gradle to build and i cant find a way to pass an environment variable to the task to run the unit tests. the only way to do so seems to be to add environment to the build.gradle. i also cant find where the tasks are defined.
Can’t help you more without code.
GitHub - wpilibsuite/allwpilib: Official Repository of WPILibJ and WPILibC it also uses GitHub - wpilibsuite/GradleRIO: The official gradle plugin for the FIRST Robotics Competition as a gradle plugin. this is from one of the maintainers “// you are not expected to understand this” so i might be cooked
What nix code have you written? Have you tried wrapping using the nix tooling for gradle?
i have looked at it however the mitm cache requires you to build it with an internet connection( which im trying to use a shell for) so it can hash the deps for the nix build.
this is my shell so far
{
mkShell,
libgcc,
gfortran,
libglvnd,
wayland,
stdenv,
xorg,
bazelisk,
libGL,
temurin-bin,
lib,
cmake,
gradle,
ninja,
vcpkg,
protobuf,
opencv,
libssh,
zlib,
}:
mkShell.override
{
# Override stdenv in order to change compiler:
# stdenv = pkgs.clangStdenv;
}
{
packages = [
libgcc
gfortran
libglvnd
wayland
stdenv.cc.cc
xorg.libX11
bazelisk
temurin-bin
cmake
gradle
ninja
vcpkg
protobuf
opencv
libssh
zlib
];
buildInputs = [
stdenv.cc.cc
xorg.libX11
libgcc
protobuf
opencv
libssh
zlib
];
nativeBuildInputs = [
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXinerama
xorg.libXi
libGL
stdenv.cc.cc
libgcc
vcpkg
cmake
protobuf
opencv
libssh
zlib
];
hardeningDisable = [ "fortify" ];
shellHook = "zsh";
LD_LIBRARY_PATH = lib.makeLibraryPath [
libgcc
];
}
i then just use call package in my flake to use it
gcc/cc is already part of the shell, so remove that, and packages is the same as nativeBuildInputs. In a shell buildInputs is unnecessary.
Setting LD_LIBRARY_PATH is generally incorrect too.
Some how removing stdenv.cc.cc from all of the inputs made the jni work right im not exactly sure how that works but im glad it does. but this is the new shell
{
mkShell,
gfortran,
xorg,
bazelisk,
libGL,
temurin-bin,
cmake,
gradle,
ninja,
vcpkg,
protobuf,
opencv,
libssh,
zlib,
}:
mkShell {
packages = [
gfortran
bazelisk
temurin-bin
cmake
gradle
ninja
vcpkg
protobuf
opencv
libssh
zlib
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXinerama
xorg.libXi
libGL
];
hardeningDisable = [ "fortify" ];
shellHook = "zsh";
}