This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: C API in debug fails
Type: behavior Stage:
Components: C API, Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Banger, loewis, pitrou
Priority: normal Keywords:

Created on 2014-04-17 21:51 by Banger, last changed 2022-04-11 14:58 by admin.

Messages (6)
msg216759 - (view) Author: Steve (Banger) Date: 2014-04-17 21:51
Although not a bug, it annoys me enough that it is a bug in my head!

The problem is that trying to compile an application in debug that embeds Python fails.

Case in point; we canned the idea of embedding Python (went with Lua) for that reason only.  We did not have the option of incorporating a Python build into our build system and not being able to compile in debug was not an option either.  We would have been happy to compile in debug with a release lib of Python, but since it was not possible, it got killed.

The fix: It should be possible for someone to compile an application in debug that embeds python without having the Python debug libraries.
msg216760 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-04-17 21:52
Is that under Windows?
msg216785 - (view) Author: Steve (Banger) Date: 2014-04-18 15:58
It is under windows
msg216786 - (view) Author: Steve (Banger) Date: 2014-04-18 16:36
A bit more info:
- When building in debug you need the Pythonxx_d.lib.
- This lib does not come with the normal install (or any other install).  That part is fine and normal (you don't include debug libs with install).
- To get that lib you have to build Python in debug to get it.  This is too much, I should not have to rebuild a library just because I want to build MY application in debug.
- Copying the Pythonxx.lib file to Pythonxx_d.lib works for many basic functions, but for others, it is missing necessary defiitions (i.e. linking fails).
msg216853 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-04-19 09:13
I think the issue is actually slightly different. You can certainly build your Python "in debug", and still link with the release mode Python. The question is what "in debug" means, and the normal definition would be "with the generation of debug symbols by the compiler".

What you cannot do is
1. to build with _DEBUG defined (or whatever the exact spelling of the macro is, or
2. to link with the debug version of msvcrt.

We could fix 1, i.e. allowing you to define _DEBUG, and still bind the release version. I think we cannot reasonably fix 2; this is a Microsoft issue.

You can work around by simply not defining _DEBUG, and still build "in debug"
msg217147 - (view) Author: Steve (Banger) Date: 2014-04-25 03:26
Indeed, but not defining _DEBUG for debug compiling is not realistic.  Too many dependencies.  I am not even sure it would work, because if we bind with the debug libraries, but build with the "release" headers, it might break.  In any case it is not an option we have on the table at this moment.

As for the linking part, I am not sure I am following you.  Your runtime libraries and DLLs should not need to be linked to anything.  They may be dependent on the release msvcrt, and that is fine (like I said, we can live with the Python parts in release).  We have many other such libraries that are only in release mode (even when we build in debug).
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65491
2020-06-25 09:40:09vstinnersetcomponents: + C API
2014-04-25 03:26:58Bangersetmessages: + msg217147
2014-04-19 09:13:33loewissetmessages: + msg216853
2014-04-18 16:36:03Bangersetmessages: + msg216786
2014-04-18 15:59:25pitrousetnosy: + loewis
2014-04-18 15:58:27Bangersetmessages: + msg216785
2014-04-17 21:52:13pitrousetnosy: + pitrou
messages: + msg216760
2014-04-17 21:51:18Bangercreate