# Merge topic 'allow-optional-python-linking' fails in Windows.

**URL:** https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151
**Category:** Development
**Created:** [June 15, 2019, 2:37am UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151 "2019-06-15T02:37:57Z")
**Posts on this page:** 8
**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: [June 15, 2019, 2:37am UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/1 "2019-06-15T02:37:57Z")

</div>

@ben.boeckel, this merge causes a build failure wrt Python wrapping in Windows.

It seems the linker is unable to find the Python library:

```auto
LINK : fatal error LNK1104: cannot open file 'python37.lib'

```

I can get a build if I set VTK\_PYTHON\_OPTIONAL\_LINK to OFF.

This popped up a while back in [VTK\_PYTHON\_OPTIONAL\_LINK](https://discourse.vtk.org/t/vtk-python-optional-link/484)

---

<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: [June 17, 2019, 1:34pm UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/2 "2019-06-17T13:34:13Z")

</div>

Hmm. Our Windows Python builders are OK with it. That line seems to indicate that there is autolinking going on somewhere. Maybe this is new in 3.6? I think we only test up to 3.5 now and Windows is a 3.5 tester.

---

<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: [June 17, 2019, 1:37pm UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/3 "2019-06-17T13:37:07Z")

</div>

Hrm, yep, I see autolinking in `pyconfig.h`. There’s no way to disable it either 😕 . Seems we have to disable its addition either ☹ . Though it isn’t new in 3.6 either. So I guess the question is: why is it working on `mun`?

---

<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: [June 18, 2019, 9:30am UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/4 "2019-06-18T09:30:51Z")

</div>

@ben.boeckel I hope you find out what’s happening on **mun**! I spent a lot of time trying many things, including deleting everything and rebuilding, and I was even considering reverting to an older version of Visual Studio as a last resort. However when I was writing this post, Discourse picked up the older post I referred to. So I was able to build based on the comments in that! So Discourse works!  
One other thing is that I am using Anaconda Python, but that shouldn’t matter.

---

<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: [June 18, 2019, 11:52am UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/5 "2019-06-18T11:52:23Z")

</div>

> [@amaclean](#):
>
> One other thing is that I am using Anaconda Python, but that shouldn’t matter.

Well, Anaconda (frustratingly) tends to build their Python versions differently than [python.org](http://python.org) binaries (which is what we’re using). @danlipsa did you encounter any Windows issues with the Anaconda VTK you were working on?

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [June 18, 2019, 12:44pm UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/6 "2019-06-18T12:44:16Z")

</div>

I have not tested on windows. We don’t use Windows packages but rather Unix packages under the Windows’s Unix subsystem.

---

<div class="post-metadata">

### Author: ![jcfr](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jcfr/32/466_2.png) [@jcfr](https://discourse.vtk.org/u/jcfr)
#### Post date: [June 19, 2019, 12:12am UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/7 "2019-06-19T00:12:09Z")

</div>

On windows, it is indeed required to link against the python library, there are no use of weak linking and the python shared library is always distributed 1, 2

1 This is always true when dealing with a CPython distribution able to load python modules.  
2 In the case of statically built CPython distribution, no shared library would be available but that is an unrelated usecase

---

<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: [June 19, 2019, 12:51pm UTC](https://discourse.vtk.org/t/merge-topic-allow-optional-python-linking-fails-in-windows/1151/8 "2019-06-19T12:51:47Z")

</div>

OK, so we should then add `NOT WIN32` to that conditional then.
