imagej / imagej-launcher

The ImageJ native launcher
https://imagej.net/learn/launcher
BSD 2-Clause "Simplified" License
21 stars 23 forks source link

Zulu JDK failing to load native libs on windows #91

Open hinerm opened 1 year ago

hinerm commented 1 year ago

It looks like the launcher is not configuring the java.library.path in a way that's compatible with the Zulu JDK.

See this forum thread.

mkitti commented 1 year ago

I've been trying to chase this one down for a while now as well: https://forum.image.sc/t/imagej-tensorflow-now-with-command-to-change-tensorflow-library-version-switch-to-gpu/31744/24?u=markkitt

mkitti commented 1 year ago

My theory is that something is getting confused by the inconsistent use of slashes and backslashes. What's strange is that some are reporting that this could be dependent on the shell / command prompt. There is also possible environment variable involvement.

Regarding environment variable involvement we are using putenv: https://github.com/imagej/imagej-launcher/blob/47befcbde8ce3ce114b590764a86caa6c2b4e654/src/main/c/platform.c#L701

This is actually deprecated: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv?view=msvc-170

_putenv_s is preferred with regard to the C Runtime: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-wputenv?view=msvc-170 https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s?view=msvc-170

The problem with Windows is that there is often more than one C Runtime (CRT) lying around. What we really want to do is set it for the entire process tree. In that case we may want to use

SetEnvironmentVariable and GetEnvironmentVariable from the Win32 API: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable

The blocker for me in solving this is that I cannot reproduce the issue yet.

mkitti commented 1 year ago

Can someone figure out how to reproduce the issue?