I have a C application that is using a function from the Gem5 operations called "m5_dumpreset_stats()".
So, I did the following, I included the header file of this function:
#include "../gem5-stable/util/m5/m5op.h"
then in my source file I called the function:
void foo()
{
m5_dumpreset_stats(0,0);
/* For loop */
m5_dumpreset_stats(0,0);
}
To build my project I'm using a Makefile :
CC=arm-linux-gnueabi-gcc
CFLAGS=-g -c -Wall -O3 -mfpu=neon
LDFLAGS=-static
SOURCES=$ foo.c
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=foo
all: $(TASKMAP) $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -lm -o $@
.c.o:
$(CC) $(CFLAGS) $< -lm -o $@
clean:
rm -fr $(OBJECTS) $(EXECUTABLE)
My first guess is that I have to link the library using the Makefile but honestly, I don't know how? Could someone show me the right way to do it?
P.S : m5_dumpreset_stats(delay,period): Save and reset simulation statistics to a file in delay nanoseconds; repeat this every period nanoseconds.
Thank you for your contributions. This was my solution: See that I'm using ARM core for simulation I used Makefile.arm to generate a library called "m5" then I had to do following changes in my own Makefile:
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -lm -L"/home/anoir/gem5-stable/util/m5" -lm5 -o $@
and I kept the inclusion in my header file to call m5op.h like this:
#include "/home/anoir/gem5-stable/util/m5/m5op.h"
Finally, I've tested it in the simulator and checked the stats file and Works perfectly Thanks to you.