I downloaded gdb 9.1 on macOS Catalina Version 10.15.2. I am trying to debug an executable from a code written in C called test that is created in my Makefile and linked to a static library. I have tried putting -g and -ggdb at all compilation lines and linkage lines. I make sure to use make clean
every time I make changes then run make test
to rerun the Makefile. My Makefile reads as the following:
all: main
mkdir -p build/bin
mkdir -p build/lib
mkdir -p build/objects
mv *.o build/objects
mv *.a build/lib
mv main build/bin
main: main.o liblinkedlist.a
gcc main.o -g -o main -llinkedlist -L.
test: test.o liblinkedlist.a
gcc test.o -g -o test -llinkedlist -L.
mkdir -p build/bin
mkdir -p build/lib
mkdir -p build/objects
mv *.o build/objects
mv *.a build/lib
test.o: src/bin/test.c
gcc src/bin/test.c -g -c -I include
main.o: src/bin/main.c
gcc -g src/bin/main.c -c -I include
liblinkedlist.a: src/lib.c
gcc src/lib.c -g -c -I include
ar rs liblinkedlist.a lib.o
clean:
rm -rf build
rm -f test
rm -f main
When I try to do gdb ./test
it gives me the following lines of code in the terminal:
Reading symbols from ./test...
warning: Could not open OSO archive file "/Users/eamonohare/Desktop/Spring_2020_Classes/CSE_109/homework-3/./liblinkedlist.a"
warning: `/Users/eamonohare/Desktop/Spring_2020_Classes/CSE_109/homework-3/test.o': can't open to read symbols: No such file or directory. (No debugging symbols found in ./test)
(gdb)
I have tried the solution to every other user having this problem and none of them worked. I am not sure how I can solve this.
place the source code, the object file, and the executable file in the same directory as where you are running gdb
There are other ways, which require some simple commands into gdb
before entering run
, however; they are a nuisance to redo over and over.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.