Das Problem tritt auf, wenn ich versuche, den C++-Code in Visual Studio 2022 zu debuggen. Ich kann den Python-Code ohne Fehler debuggen, aber wenn ich den Code debuggen möchte, kann ich keine Symbole aus C++ laden.
Ich habe versucht, dieser Anleitung zu folgen: https://learn.microsoft.com/en-us/visua ... ew=vs-2022
(Aber ich kann in Schritt 2 von Mischmodus-Debugging in einem Python-Projekt aktivieren nicht sowohl Native als auch Python aktivieren. Wenn ich Python im Codetyp auswählen auswähle, erhalte ich diese Fehlermeldung: „Python-Debugging ist nicht möglich.“ Kompatibel mit Native. Möchten Sie „Native“ deaktivieren? und konnte Haltepunkte erstellen und festlegen, als ich das Debuggen mit dem C++-Projekt als Startprojekt startete (wie im YouTube-Tutorial beschrieben). Das Problem tritt auf, wenn ich versuche, es mit der PythonApplication als Startprojekt zu tun. (Ich habe versucht, sowohl Python39-64 als auch Python310-64 zu verwenden)
Ich habe den Inhalt der notwendigen Dateien hinzugefügt, um das Problem zu reproduzieren. Dies ist die Lösungsdatei:
Code: Select all
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spam", "spam\spam.vcxproj", "{18FA7E0B-56F8-433D-ABCC-523E412FFB83}"
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "PythonApplication", "PythonApplication\PythonApplication.pyproj", "{DD2AA21D-1713-4B24-AB58-2695C05684C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Debug|Any CPU.ActiveCfg = Debug|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Debug|Any CPU.Build.0 = Debug|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Debug|x64.ActiveCfg = Debug|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Debug|x64.Build.0 = Debug|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Debug|x86.ActiveCfg = Debug|Win32
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Debug|x86.Build.0 = Debug|Win32
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Release|Any CPU.ActiveCfg = Release|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Release|Any CPU.Build.0 = Release|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Release|x64.ActiveCfg = Release|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Release|x64.Build.0 = Release|x64
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Release|x86.ActiveCfg = Release|Win32
{18FA7E0B-56F8-433D-ABCC-523E412FFB83}.Release|x86.Build.0 = Release|Win32
{DD2AA21D-1713-4B24-AB58-2695C05684C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD2AA21D-1713-4B24-AB58-2695C05684C1}.Debug|x64.ActiveCfg = Debug|Any CPU
{DD2AA21D-1713-4B24-AB58-2695C05684C1}.Debug|x86.ActiveCfg = Debug|Any CPU
{DD2AA21D-1713-4B24-AB58-2695C05684C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD2AA21D-1713-4B24-AB58-2695C05684C1}.Release|x64.ActiveCfg = Release|Any CPU
{DD2AA21D-1713-4B24-AB58-2695C05684C1}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A9526BE0-4988-4327-B7A0-AFD3DF109D47}
EndGlobalSection
EndGlobal
Code: Select all
Debug
2.0
dd2aa21d-1713-4b24-ab58-2695c05684c1
.
PythonApplication.py
.
.
PythonApplication
PythonApplication
MSBuild|venv10|$(MSBuildProjectFullPath)
Standard Python launcher
True
true
false
true
false
venv10
3.10
venv10 (Python 3.10 (64-bit))
Scripts\python.exe
Scripts\pythonw.exe
PYTHONPATH
X64
Code: Select all
import spam
print(spam.add_one(123))
Code: Select all
Debug
Win32
Release
Win32
Debug
x64
Release
x64
16.0
Win32Proj
{18fa7e0b-56f8-433d-abcc-523e412ffb83}
spam
10.0
Application
true
v143
Unicode
Application
false
v143
true
Unicode
DynamicLibrary
true
v143
Unicode
Application
false
v143
true
Unicode
c:\Python310-64\include;$(IncludePath)
$(SolutionDir)\PythonApplication\
.pyd
Level3
true
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
Console
true
Level3
true
true
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
Console
true
true
true
Level3
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
Console
true
C:\Python310-64\libs;%(AdditionalLibraryDirectories)
Level3
true
true
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
Console
true
true
true
Code: Select all
#include "include.h"
PyObject* some_function(PyObject* self, PyObject* args)
{
__int64 input_value;
if (!PyArg_ParseTuple(args, "L", &input_value))
{
goto error;
}
return PyLong_FromLongLong(input_value + 1);
error:
return 0;
}
PyMethodDef SpamMethods[] =
{
{"add_one",(PyCFunction)some_function, METH_VARARGS, 0},
{0,0,0,0}
};
static struct PyModuleDef spammodule = {
PyModuleDef_HEAD_INIT,
"spam", /* name of module */
"spam_doc", /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
SpamMethods
};
PyMODINIT_FUNC
PyInit_spam(void)
{
return PyModule_Create(&spammodule);
}
Code: Select all
#if defined(_MSC_VER) && defined(_DEBUG)
#undef _DEBUG
#include
#define _DEBUG 1
#else
#include
#endif
**Mein ursprünglicher Text: **
Ich habe den Code mit Debug-Informationen usw. erstellt und das native Debugging im Python-Projekt in VS 2022 aktiviert, und wenn ich den Code mit Debugging ausführe, werden die Haltepunkte in C++ nicht erreicht. (Die Dateien pdb, pyd, lib und exp sollten die Erweiterung project_name.cp310-win_amd64.pdb für Python 3.10-64 haben, oder?)
Ich kann auch sehen, dass die Symbole für meine 4 C++-Projekte nicht geladen werden (Screenshot der geladenen Module nach dem Anhalten des Debuggens, während der Code ausgeführt wird):

Im Vergleich zur Liste der Module, wenn ich das Projekt mit Python 3.7.0 ausführe:

Ich habe versucht, das Projekt in vscode auszuführen, aber ich kann es auch nicht dazu bringen, das Debugging dort zu laden. Irgendwelche Vorschläge, wie man die Symbole lädt?
Mobile version