下面的Make文件未使用调试信息进行编译。
有人可以建议出什么问题吗?我不是makefile专家。
我尝试添加-g选项。我该怎么办?
这与这篇文章有关-我不能在Visual Studio代码中使用gdb吗?
Issue while debugging Linux based C++ code visual studio code
谢谢
EXEC = deserialize
WARNING_FLAGS := -pedantic-errors -Wall -Wextra -Werror -Wno-format-security
COMPILATION_FLAGS := -std=c++17 -fPIC -fconcepts -c -g
INCLUDES := -I../flatbuffers/include -I.
LIBS := -lstdc++
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp, %.o, $(wildcard *.cpp))
STANDALONE_HEADERS :=
LIB := graph.so
LIB_OBJS := $(filter-out main.o,$(OBJS))
LIB_FLAGS := -shared
# .PHONY: all clean
%.o: %.cpp
gcc $^ $(INCLUDES) $(LIBS) $(COMPILATION_FLAGS) $(WARNING_FLAGS) \
-o $@ $(STANDALONE_HEADERS) -g
$(LIB): $(LIB_OBJS)
gcc $(LIB_OBJS) $(LIBS) $(LIB_FLAGS) -g -o $@
$(EXEC): $(LIB) main.o
# gcc main.o $(LIB) $(LIBS) -o $(EXEC)
# sudo ldconfig
gcc main.o -L . -l:graph.so $(LIBS) -o $(EXEC) -g
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(PWD);
all: clean $(EXEC)
clean:
-rm *.o $(EXEC)
我在VS代码中的task.json
文件是:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/project/main",
"args": [],
"stopAtEntry": true,
"cwd": "/project",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build tool"
}
] }
VS代码调试器中的错误是:
由于共享库事件而停止(未添加或删除库) 已加载'/lib64/ld-linux-x86-64.so.2'。符号已加载。 [下等1 (进程13729)以代码0177退出]该程序 '/项目/主要' 已退出,代码为177(0x000000b1)。