Problem with java bindings in VTK 9

Things are getting past where they were before, will keep you updated.

OK @ben.boeckel one, maybe last?, problem - when I try to run it, pointing to the jnilibs as needed (setting DYLD_LIBRARY_PATH, setting java.library.path) the jnilib want to reference the dylib files, which it canā€™t find because they are no longer in that directory.

If I copy the dylibs from 2 directories up into that natives folder, and run, it doesnā€™t complain about the missing files, but then crashes horribly with the vtkGenericOpenGLRenderWindow crash (which I have a fix forā€¦ I need to make a MR for itā€¦ basically you need to ask for the best GLProfile you can instead of the defaultā€¦ Iā€™ll see if I can do that tonite)

If you can tackle the jnilibs, Iā€™ll get a MR in for the hard crash (and hope it still works!)

Could you paste the result of:

otool -l $any_jnilib | grep -A4 LC_RPATH

(the 4 may need tweaking to get the actual value). It should be @loader_path/../... I guess the output of otool -L $any_jnilib may also be useful.

Sure. here is the grep result:

otool -l libvtkRenderingParallelJava.jnilib | grep -A4 LC_RPATH
          cmd LC_RPATH
      cmdsize 32
         path @loader_path (offset 12)
Load command 35
          cmd LC_RPATH
      cmdsize 32
         path @loader_path/../../ (offset 12)

and here is the full one:

otool -l libvtkRenderingParallelJava.jnilib
libvtkRenderingParallelJava.jnilib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x00           6    36       2728 0x00110085
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 472
  segname __TEXT
   vmaddr 0x0000000000000000
   vmsize 0x000000000000f000
  fileoff 0
 filesize 61440
  maxprot 0x00000005
 initprot 0x00000005
   nsects 5
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000000007910
      size 0x0000000000007210
    offset 30992
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x000000000000eb20
      size 0x0000000000000114
    offset 60192
     align 2^1 (2)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 6 (size of stubs)
Section
  sectname __stub_helper
   segname __TEXT
      addr 0x000000000000ec34
      size 0x00000000000001d2
    offset 60468
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x000000000000ee06
      size 0x000000000000019c
    offset 60934
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x000000000000efa4
      size 0x000000000000005c
    offset 61348
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 472
  segname __DATA
   vmaddr 0x000000000000f000
   vmsize 0x0000000000001000
  fileoff 61440
 filesize 4096
  maxprot 0x00000003
 initprot 0x00000003
   nsects 5
    flags 0x0
Section
  sectname __nl_symbol_ptr
   segname __DATA
      addr 0x000000000000f000
      size 0x0000000000000008
    offset 61440
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 46 (index into indirect symbol table)
 reserved2 0
Section
  sectname __got
   segname __DATA
      addr 0x000000000000f008
      size 0x0000000000000028
    offset 61448
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 47 (index into indirect symbol table)
 reserved2 0
Section
  sectname __la_symbol_ptr
   segname __DATA
      addr 0x000000000000f030
      size 0x0000000000000170
    offset 61488
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000007
 reserved1 52 (index into indirect symbol table)
 reserved2 0
Section
  sectname __mod_init_func
   segname __DATA
      addr 0x000000000000f1a0
      size 0x0000000000000018
    offset 61856
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000009
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x000000000000f1b8
      size 0x0000000000000006
    offset 0
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000000010000
   vmsize 0x0000000000015000
  fileoff 65536
 filesize 84296
  maxprot 0x00000001
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 3
          cmd LC_ID_DYLIB
      cmdsize 64
         name libvtkRenderingParallelJava.jnilib (offset 24)
   time stamp 1 Wed Dec 31 19:00:01 1969
      current version 0.0.0
compatibility version 0.0.0
Load command 4
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 65536
    rebase_size 8
       bind_off 65544
      bind_size 240
  weak_bind_off 65784
 weak_bind_size 32
  lazy_bind_off 65816
 lazy_bind_size 2560
     export_off 68376
    export_size 7768
Load command 5
     cmd LC_SYMTAB
 cmdsize 24
  symoff 76488
   nsyms 1779
  stroff 105344
 strsize 44488
Load command 6
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 1457
     iextdefsym 1457
     nextdefsym 271
      iundefsym 1728
      nundefsym 51
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 104952
  nindirectsyms 98
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 7
     cmd LC_UUID
 cmdsize 24
    uuid 57676E10-1315-38BA-9F9E-FAE4F54E3FAA
Load command 8
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.9
      sdk 10.15.4
Load command 9
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name libvtkRenderingParallel-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 11
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkCommonCoreJava.jnilib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 0.0.0
compatibility version 0.0.0
Load command 12
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkRenderingCoreJava.jnilib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 0.0.0
compatibility version 0.0.0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name libvtkRenderingOpenGL2Java.jnilib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 0.0.0
compatibility version 0.0.0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name libvtkJava-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 15
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name libvtkRenderingOpenGL2-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 16
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkRenderingUI-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 17
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 23.0.0
compatibility version 1.0.0
Load command 18
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name libvtkglew-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 19
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 1.0.0
compatibility version 1.0.0
Load command 20
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkRenderingCore-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 21
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkFiltersCore-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 22
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name libvtkCommonExecutionModel-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 23
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name libvtkCommonDataModel-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 24
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name libvtkCommonTransforms-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 25
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkCommonMisc-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 26
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkCommonMath-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 27
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name libvtkCommonCore-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 28
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name libvtksys-9.0.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 9.0.0
compatibility version 1.0.0
Load command 29
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 1.0.0
compatibility version 1.0.0
Load command 30
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 902.1.0
compatibility version 1.0.0
Load command 31
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 1281.100.1
compatibility version 1.0.0
Load command 32
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 76144
 datasize 344
Load command 33
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 76488
 datasize 0
Load command 34
          cmd LC_RPATH
      cmdsize 32
         path @loader_path (offset 12)
Load command 35
          cmd LC_RPATH
      cmdsize 32
         path @loader_path/../../ (offset 12)

OK, so thatā€™s what Iā€™d expect. What is otool -L $any_jnilib saying? I wonder if weā€™re not getting @rpath/ library IDsā€¦

Hereā€™s what that gives below. Note that in my custom script Iā€™ve using (which really just lets me set cmake parameters without going through ccmake first), Iā€™ve had to add the following flags to get these to generate properly in the past

-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
-DCMAKE_MACOSX_RPATH=OFF

Maybe they arenā€™t needed anymore? Anyone otool output below:

otool -L libvtkRenderingParallelJava.jnilib
libvtkRenderingParallelJava.jnilib:
	libvtkRenderingParallelJava.jnilib (compatibility version 0.0.0, current version 0.0.0)
	libvtkRenderingParallel-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonCoreJava.jnilib (compatibility version 0.0.0, current version 0.0.0)
	libvtkRenderingCoreJava.jnilib (compatibility version 0.0.0, current version 0.0.0)
	libvtkRenderingOpenGL2Java.jnilib (compatibility version 0.0.0, current version 0.0.0)
	libvtkJava-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkRenderingOpenGL2-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkRenderingUI-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	libvtkglew-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	libvtkRenderingCore-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkFiltersCore-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonExecutionModel-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonDataModel-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonTransforms-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonMisc-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonMath-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtkCommonCore-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	libvtksys-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
	/System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

Yes, please try with those rpath settings left to the default values.

Any update if you donā€™t set those rpath variables? Iā€™d like to merge whatā€™s there so it can make it into 9.0.

Iā€™ll run that tonite and let you know.

1 Like

Sorry for the delay; still getting errors where the loading of the jnilib tries to reference the dylib. Were you able to get the demo (JoglConeRendering) to run correctly?

Iā€™d have to get a Mac to test that part. Iā€™ll try the build on a Mac if I can find one with Java around and see if I canā€™t get the rpaths to look right there.

Hmm. With stock settings Iā€™m seeing:

Build tree

% otool -L lib/java/vtk-Darwin-x86_64/libvtkCommonCoreJava.jnilib
lib/java/vtk-Darwin-x86_64/libvtkCommonCoreJava.jnilib:
        @rpath/libvtkCommonCoreJava.jnilib (compatibility version 0.0.0, current version 0.0.0)
        @rpath/libvtkJava-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
        @rpath/libvtkCommonCore-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
        @rpath/libvtksys-9.0.1.dylib (compatibility version 1.0.0, current version 9.0.0)
        /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
% otool -l lib/java/vtk-Darwin-x86_64/libvtkCommonCoreJava.jnilib | grep -A2 LC_RPATH
          cmd LC_RPATH
      cmdsize 72
         path /Users/boeckb/code/depot/group-kitware/vtk/build/lib (offset 12)

The install tree looks the same; looking into that. But it looks OK here. Iā€™d look to see if you have something not making @rpath/ be used in your build. What CMake are you using?

OK, so the install tree looks fine too if I donā€™t use whatever install_name_tool macports is shipping. Iā€™m going to put this down to some other configuration setting issue and merge the branch as-is. We can follow up with further fixes if needed.

OK Iā€™ll take a look at it again soon. Can you elaborate on what ā€œstock settingsā€ you are using - I assume this refers to the cmake settings?

ā€œStockā€ as in I only set the Java wrapper settings and manipulate module selection. No CMAKE_ variable changes.

Hey @ben.boeckel did you try running the sample Java code (like JoglConeRendering) after building your libs? I got my building correctly (@rpath is now there) with the latest master, but am getting some nasty Invalid framebuffer operation errors when trying to run the demo.

How can I run the JoglConeRendering example?

Seems to work just fine on Linux. Looks to be some spheres of different colors that pop in and out of existence?

Actually the last argument (the main to execute) should be vtk.sample.rendering.JoglConeRendering rather than vtk.sample.Demo but at least you have the rest of the command line. :wink: