C++ 为什么突破点没有被击中?
我不久前开始使用Linux,我正在尝试运行一些为windows编写的旧代码。它们正在运行,但我无法调试,断点没有被击中。我已经看到,这方面的许多问题都与没有在“MakeFile”中添加“-g”有关,但我的情况似乎并非如此。我使用的是Vscode,我的断点在调试过程中是这样的 这是我的制作文件:C++ 为什么突破点没有被击中?,c++,c,debugging,visual-studio-code,C++,C,Debugging,Visual Studio Code,我不久前开始使用Linux,我正在尝试运行一些为windows编写的旧代码。它们正在运行,但我无法调试,断点没有被击中。我已经看到,这方面的许多问题都与没有在“MakeFile”中添加“-g”有关,但我的情况似乎并非如此。我使用的是Vscode,我的断点在调试过程中是这样的 这是我的制作文件: CC=gcc CFLAGS= -o -W -ggdb -g LDFLAGS= -lm -lstdc++ OBJFILES = main.o Funcoes.o Mat_
CC=gcc
CFLAGS= -o -W -ggdb -g
LDFLAGS= -lm -lstdc++
OBJFILES = main.o Funcoes.o Mat_Vet.o rotinas_matematicas.o Classes.o SME5720.o
TARGET = ss
all: $(TARGET)
$(TARGET): $(OBJFILES)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJFILES) $(LDFLAGS)
clean:
rm -f $(OBJFILES) $(TARGET) *~
以下是我的json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/ss",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
通过更改“MakeFile”解决了我的问题,我不知道为什么它会工作。如果有人能说出原因。这是我的新生成文件:
output: main.o Classes.o Funcoes.o Mat_Vet.o rotinas_matematicas.o SME5720.o
g++ main.o Classes.o Funcoes.o Mat_Vet.o rotinas_matematicas.o SME5720.o -o output
main.o:main.cpp
g++ -c -g main.cpp
Classes.o: Classes.cpp Classes.h
g++ -c -g Classes.cpp
Funcoes.o: Funcoes.cpp Funcoes.h
g++ -c -g Funcoes.cpp
Mat_Vet.o: Mat_Vet.cpp Mat_Vet.h
g++ -c -g Mat_Vet.cpp
rotinas_matematicas.o: rotinas_matematicas.cpp rotinas_matematicas.h
g++ -c -g rotinas_matematicas.cpp
SME5720.o: SME5720.cpp SME5720.h
g++ -c -g SME5720.cpp
clean:
rm *.o output
只有在调试器下运行代码时,断点才有意义。是吗?
CFLAGS=-o…
这里的-o
选项没有任何意义。是的,我在调试程序下运行我的代码。调试时它是否在入口处停止?是的,它只忽略我处理的断点。