The Make file below is not compiling with debugging information.
Could anybody suggest what is wrong? I'm not a makefile expert.
I've tried adding the -g options. What else should I do?
This is related to this post - I can't use gdb in visual studio code?
Issue while debugging Linux based C++ code visual studio code
Thanks
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)
My task.json
file in VS code is:
{
"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"
}
] }
The error in the VS code debugger is:
Stopped due to shared library event (no libraries added or removed) Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded. [Inferior 1 (process 13729) exited with code 0177] The program '/project/main' has exited with code 177 (0x000000b1).
User contributions licensed under CC BY-SA 3.0