# Cannot open file 'python311\_d.lib'

**URL:** <https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399>\
**Category:** Python Help\
**Tags:** c-api\
**Created:** [August 27, 2023, 1:54pm UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399 "2023-08-27T13:54:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![usersever](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/usersever/32/14341_2.png) [@usersever](https://discuss.python.org/u/usersever)\
**Post date:** [August 27, 2023, 1:54pm UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/1 "2023-08-27T13:54:58Z")

</div>

how can i fix this

```auto
|---|---|---|---|---|---|---|
|Error|LNK1104|cannot open file 'python311_d.lib'|Project|...Project\LINK|1||

```

this is my code:

```auto
#include <Python.h>

int main() {
	Py_Initialize();
		PyRun_SimpleString("print(python trong c++)");
	Py_Finalize();
}

```

---

<div class="post-metadata">

**Author:** ![kanhaiya](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@kanhaiya](https://discuss.python.org/u/kanhaiya)\
**Post date:** [August 27, 2023, 2:22pm UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/2 "2023-08-27T14:22:07Z")

</div>

[quote=“Bảo Nguyễn, post:1, topic:32399, username:usersever”]  
`Py_Initialize();` coding

---

<div class="post-metadata">

**Author:** ![usersever](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/usersever/32/14341_2.png) [@usersever](https://discuss.python.org/u/usersever)\
**Post date:** [August 27, 2023, 2:42pm UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/3 "2023-08-27T14:42:31Z")

</div>

what’s your mean

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [August 27, 2023, 5:35pm UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/4 "2023-08-27T17:35:26Z")

</div>

`python311_d.lib` is from the debug version of CPython.

If you look in `C:\Python311\libs` (or wherever you installed Python) you’ll see `python311.lib` because it’s the release version of CPython.

If you need `python311_d.lib`, you’ll need to make a debug build of CPython from the source that’s on GitHub.

When I’m building extensions for CPython, I avoid that problem by making a release version instead, although I do disable optimisations while I’m working on it so that I can single-step through the code more easily.

---

<div class="post-metadata">

**Author:** ![usersever](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/usersever/32/14341_2.png) [@usersever](https://discuss.python.org/u/usersever)\
**Post date:** [August 28, 2023, 12:59am UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/5 "2023-08-28T00:59:45Z")

</div>

how can i get License file to build this:  
my build log:

```auto
4>E:\download\Compressed\cpython-3.11.5\PCbuild\regen.targets(127,5): warning : License file E:\download\Compressed\cpython-3.11.5\externals\libffi-3.4.4\LICENSE is missing
4>E:\download\Compressed\cpython-3.11.5\PCbuild\regen.targets(127,5): warning : License file E:\download\Compressed\cpython-3.11.5\externals\openssl-bin-3.0.9\amd64\LICENSE is missing
4>E:\download\Compressed\cpython-3.11.5\PCbuild\regen.targets(127,5): warning : License file E:\download\Compressed\cpython-3.11.5\externals\tcltk-8.6.12.1\amd64\tcllicense.terms is missing
4>E:\download\Compressed\cpython-3.11.5\PCbuild\regen.targets(127,5): warning : License file E:\download\Compressed\cpython-3.11.5\externals\tcltk-8.6.12.1\amd64\tklicense.terms is missing
4>E:\download\Compressed\cpython-3.11.5\PCbuild\regen.targets(127,5): warning : License file E:\download\Compressed\cpython-3.11.5\externals\tcltk-8.6.12.1\amd64\tixlicense.terms is missing

```

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [August 28, 2023, 1:03am UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/6 "2023-08-28T01:03:53Z")

</div>

Those are warnings, not errors, so they shouldn’t affect building CPython.

---

<div class="post-metadata">

**Author:** ![usersever](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/usersever/32/14341_2.png) [@usersever](https://discuss.python.org/u/usersever)\
**Post date:** [August 28, 2023, 2:28am UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/7 "2023-08-28T02:28:00Z")

</div>

oh, i found this error

```auto
4> File "E:\download\Compressed\cpython-3.11.5\PC\validate_ucrtbase.py", line 8, in <module>
4> from ctypes import (c_buffer, POINTER, byref, create_unicode_buffer,
4> File "E:\download\Compressed\cpython-3.11.5\Lib\ctypes\ __init__.py", line 8, in <module>
4> from _ctypes import Union, Structure, Array
4>ModuleNotFoundError: No module named '_ctypes'

```

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [August 28, 2023, 2:33am UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/8 "2023-08-28T02:33:41Z")

</div>

The source for `_ctypes` is in `<path to cpython>/Modules/_ctypes`.

---

<div class="post-metadata">

**Author:** ![usersever](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/usersever/32/14341_2.png) [@usersever](https://discuss.python.org/u/usersever)\
**Post date:** [August 28, 2023, 2:37am UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/9 "2023-08-28T02:37:56Z")

</div>

how can I fix this?

---

<div class="post-metadata">

**Author:** ![alan0526](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/alan0526/32/17616_2.png) [@alan0526](https://discuss.python.org/u/alan0526)\
**Post date:** [February 2, 2024, 12:31am UTC](https://discuss.python.org/t/cannot-open-file-python311-d-lib/32399/10 "2024-02-02T00:31:41Z")

</div>

just undef \_DEBUG before include python.h

for example:  
#ifdef \_DEBUG  
#undef \_DEBUG  
#include \<Python.h\>  
#define \_DEBUG  
#else  
#include \<Python.h\>  
#endif
