Project

General

Profile

Bug #7083

Updated by Greg Shah over 1 year ago

h2. Environment

Windows VirtualBox VM is set up by following the steps in [[p2j:Windows 11 Virtual Machine Setup with FWD v4 and the Testcase Project]]

<pre>
java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
</pre>

h2. Code

Latest p2j @trunk@ (r14483) clean checkout.

h3. Steps to reproduce

Run @gradlew all@.

h3. Issue

The build fails on gradle task ant-native. Run @gradle ant-native --debug@ to debug it.
<pre>
22:57:57.563 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:exec] C:\clean\trunk\build\native>gcc -g -Wall -s -LC:\Java\jdk1.8.0_341\jre/lib/amd64/server/ -DNDEBUG -D_UNICODE -m64 -IC:\Java\jdk1.8.0_341\jre/..//include -IC:\Java\jdk1.8.0_341\jre/..//include/win32 -IC:\clean\trunk/src/native C:\clean\trunk/src/native\winspawn.c -o ..\..\build\native\spawn.exe -ljvm -m64
22:57:58.366 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:exec] make[1]: Leaving directory `C:/clean/trunk/build/native'
22:57:58.367 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:exec] c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ljvm
22:57:58.367 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:exec] collect2.exe: error: ld returned 1 exit status
22:57:58.367 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:exec] make[1]: *** [build] Error 1
22:57:58.367 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:exec] make: *** [spawn] Error 2
22:57:57.212 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger]
22:57:57.212 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :ant-native FAILED
</pre>

The @gcc@ command in @src/native/makefile.spawn@ has received @LDFLAGS+=-ljvm@. @-ljvm@ option is resolved as @libjvm@, which can be found in GCD Linux workstation under @/usr/lib/libjvm.so@ (symlink to @/usr/lib/jvm/default-java/jre/lib/amd64/server/libjvm.so@ created by the initial setup).

In Windows the same file is found under @%JAVA_HOME%\jre\bin\server@ and is called @jvm.dll@. Even though the path is in the System Environment PATH, the library cannot be found and it seems that's because the command looks for a file called @libjvm@ instead @jvm@.

h3. Temporal solution

Replace @-ljvm@ in @src/native/makefile.spawn@ and @src/native/makefile.launcher@ with the full path to the library @%JAVA_HOME%\jre\bin\server\jvm.dll@.

Back