In order to debug your code, debugger will need some information (eg, which line of code corresponds to this object code, in a executable).
To make this information available, you need to specifically instruct your compiler (with -g
option in
gcc
& g++
).
Suppose you have a library, which you compile using makefile (as in your case). You need to look in the makefile of library, for flags used for compilation. As in,
CC=g++
CFLAGS=-c -Wall
And then, you add -g
option in flags:
CFLAGS=-c -Wall -g
(Incase, your makefile
doesn't use CFLAGS
, you need to look for lines where compilation takes place
and add -g
option to all those lines, manually).
Then make
your library. Now, you can compile you test programs like this:
gcc -I/home/xxx/Documents/libtomcrypt-1.17/src/headers -c -g Tomcrypt_SHA-256_Bmark.c jg_timing.c -ltomcrypt
gcc -I/home/xxx/Documents/libtomcrypt-1.17/src/headers Tomcrypt_SHA-256_Bmark.o jg_timing.o -o executable -ltomcrypt
EDIT: Also note that '-g' option should be included during compilation, and not during linking (as you did ).