Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to build debug version under Windows #28

Closed
mrbean-bremen opened this issue Feb 7, 2025 · 4 comments · Fixed by #29
Closed

Failure to build debug version under Windows #28

mrbean-bremen opened this issue Feb 7, 2025 · 4 comments · Fixed by #29

Comments

@mrbean-bremen
Copy link
Contributor

After the latest change (always link statically under Windows), debug builds of kiwisolver (and possibly other modules) fail with linker errors due to missing debug symbols:

variable.obj : error LNK2001: unresolved external symbol _invalid_parameter
libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _invalid_parameter
libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _invalid_parameter
libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _invalid_parameter
constraint.obj : error LNK2001: unresolved external symbol _invalid_parameter
expression.obj : error LNK2001: unresolved external symbol _invalid_parameter
solver.obj : error LNK2001: unresolved external symbol _invalid_parameter
term.obj : error LNK2001: unresolved external symbol _invalid_parameter
libcpmtd.lib(_tolower.obj) : error LNK2001: unresolved external symbol _calloc_dbg
libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _calloc_dbg
libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _calloc_dbg
libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _calloc_dbg
...

The reason can be seen in the warning:

cl : Command line warning D9025 : overriding '/MDd' with '/MT'

e.g. while overriding the flag the debug mode is ignored.

@MatthieuDartiailh
Copy link
Member

How do you switch to debug build ? I am asking because limiting debug build to debug Python as done in #29 may still be surprising. I probably make sense to force debug in that case but we should be able to manually set it.

@mrbean-bremen
Copy link
Contributor Author

Yes, I had also been thinking about that. The check for debug Python is actually taken from Pillow (who took it from elsewhere), and it matches our use case (at least under Windows, there release and debug libraries cannot be mixed), but I guess an option would make sense.
Do you have any preference on how to set this?

@MatthieuDartiailh
Copy link
Member

(at least under Windows, there release and debug libraries cannot be mixed)

Do you have a reference about this ? The changes only affect windows so if it is true we can merge your PR.

@mrbean-bremen
Copy link
Contributor Author

Hm, can't find a good reference right now, but it boils to the following (taken from SO):

Mixing debug and release code is bad practice. The problem is that the different versions can depend on different fundamental parts of the C++ runtime library, such as how memory is allocated, structures for things like iterators might be different, extra code could be generated to perform operations (e.g. checked iterators).

Basically, mixing debug and release runtime libraries at runtime can lead to various hard-to-find problems, mostly related to memory corruption, which I have seen multiple times.
At compile time, there may be linker errors (if using static libraries) due to different referenced symbols, like in the mentioned case. As far as I know, this is only a problem under Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants