# Java Wrapping in Windows

**URL:** https://discourse.vtk.org/t/java-wrapping-in-windows/956
**Category:** Development
**Created:** [May 14, 2019, 5:49am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956 "2019-05-14T05:49:47Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [May 14, 2019, 5:49am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/1 "2019-05-14T05:49:47Z")

</div>

Is anyone having trouble building Java wrapping in Windows?

I think this commit **Add glTF reader and importer** (Mon, 8 April2019 19:25) is the culprit: b377cf79ccbd272ce7d4d508d5f6fc53f57d5f42

I’m using VTK 8.90 Java JDK 12.0.1 and this error also occurs in JDK 11.0.1.

Also JAVA\_SOURCE\_VERSION and JAVA\_TARGET\_VERSION can only be set to a maximum of 1.9

The error seems to be related to `vtkObject_Typecast`.

```bash
   Creating library lib\vtkIOGeometryJava.lib and object lib\vtkIOGeometryJava.exp
vtkGLTFDocumentLoaderJava.cxx.obj : error LNK2019: unresolved external symbol vtkObject_Typecast referenced in function vtkGLTFDocumentLoader_Typecast
bin\vtkIOGeometryJava.dll : fatal error LNK1120: 1 unresolved externals

```

After this I get:

```bash
[5/28] Compiling Java Classes
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[6/28] Creating vtk.jar
added manifest
...

```

and finally:

```bash
adding: vtk/vtkZLibDataCompressor.class(in = 724) (out= 384)(deflated 46%)
[7/28] Compiling Java Tests
ninja: build stopped: cannot make progress due to previous errors.

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 14, 2019, 7:50am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/2 "2019-05-14T07:50:15Z")

</div>

@ben.boeckel @ken-martin : what do you think of this ? look like a module dependency issue.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 14, 2019, 11:36am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/3 "2019-05-14T11:36:47Z")

</div>

Looks like `VTK::IOGeometry` needs to publicly depend on `VTK::CommonCore` now.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 14, 2019, 11:48am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/4 "2019-05-14T11:48:46Z")

</div>

Why is that ? afaik vtkGLTFDocumentLoader is used only internally in the vtkGLTFImporter.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 14, 2019, 3:07pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/5 "2019-05-14T15:07:46Z")

</div>

It’s in `classes`, not `private_classes`, so it gets wrapped. It needs to be public because `VTK::IOImport`'s `vtkGLTFImporter` uses it.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 14, 2019, 3:09pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/6 "2019-05-14T15:09:31Z")

</div>

Make sense, that is sad that this usecase is not supported though. We will try to fix it.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 14, 2019, 4:29pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/7 "2019-05-14T16:29:39Z")

</div>

What use case is not supported?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 15, 2019, 8:12am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/8 "2019-05-15T08:12:48Z")

</div>

This usecase :

vtkGLTFDocumentLoader is a class, that is not private in IOGeometry module. it is wrapped in Java as expected.

vtkGLTFImporter is a class, that is not private in IOImport, it is wrapped in Java as expected.  
vtkGLTFImporter internally use vtkGLTFDocumentLoader, so it `private_depends` IOGeometry, yet for the Java wrapping to work, it has to `depends` it, which is not great for the whole module dependency system.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [May 15, 2019, 8:51am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/9 "2019-05-15T08:51:19Z")

</div>

One other thing. I can build in Linux with no errors. So is there some Windows oddity here?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 15, 2019, 12:15pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/10 "2019-05-15T12:15:28Z")

</div>

That use case is perfectly supported. **There is a bug in the module dependency declaration.** The bug is that `VTK::CommonCore` is not declared as a public dependency of `VTK::IOGeometry`. It is public because `vtkGLTFDocumentLoader` has it as a public dependency. Fix that and the error is gone. The new build system is much stricter and this gains us things like only adding `-I` flags for directories that are actually necessary (which helps ParaView not blow out command line length limits on Windows). It also means that module dependencies need to be correct.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 15, 2019, 12:16pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/11 "2019-05-15T12:16:57Z")

</div>

Linux probably finds the symbol because it is transitively loaded through other linked libraries. The Windows linker doesn’t work in the same way, so it doesn’t find the symbol since it doesn’t transitively load `.lib` files at link time.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 15, 2019, 12:17pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/12 "2019-05-15T12:17:53Z")

</div>

Ok ! Thanks for your explanation !

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [May 15, 2019, 10:09pm UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/13 "2019-05-15T22:09:24Z")

</div>

You guys are amazing, your depth of knowledge is extraordinary. I have been puzzling over this for some time and linker differences never occurred to me.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 16, 2019, 9:23am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/14 "2019-05-16T09:23:37Z")

</div>

It has been fixed on master.  
[https://gitlab.kitware.com/vtk/vtk/merge\_requests/5540](https://gitlab.kitware.com/vtk/vtk/merge_requests/5540)

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [May 16, 2019, 9:38am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/15 "2019-05-16T09:38:57Z")

</div>

Thanks, I’ll do a build tomorrow.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [May 17, 2019, 5:27am UTC](https://discourse.vtk.org/t/java-wrapping-in-windows/956/16 "2019-05-17T05:27:12Z")

</div>

Thanks to all, build is successful in Windows and Linux.
