建構除錯版的應用程式
V1.0
email: mesmerli@hotmail.com
建構應用程式
本文實際搭配 gdbserver 6.1 與 Insight 6.1 成功驗證遠端應用程式除錯。
依下文建立以下兩個檔案:
- Makefile
- hello.c
接下來使用以下命令,編譯建構應用程式。
#make -f Makefile
Makefile
# Makefile to build application for gdbserver and Insight
SYSTEM=helloworld
ALL= $(SYSTEM)
CROSS_COMPILE = arm-linux-
LINUXDIR = /usr/src/creator/s3c2410/linux
export LINUXDIR
#
# Include the make variables (CC, etc...)
#
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
export AS LD CC CPP AR
CFLAGS= -O0 -gdwarf-2 -DHAVE_CONFIG_H -DFPM_DEFAULT -Dlinux -Dunix -DNDEBUG -D_REENTRANT -I.
#OBJS= mutex_thd1.o
#EXEC = mutex_thd1
#$(EXEC): $(OBJS)
# $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) -L/usr/local/arm/2.95.3/arm-linux/lib /usr/local/arm/2.95.3/arm-linux/lib/libpthread.a
all: $(ALL)
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
.S.o:
$(CC) $(AFLAGS) -c -o $@ $<
helloworld: helloworld.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) -L/usr/local/arm/2.95.3/arm-linux/lib /usr/local/arm/2.95.3/arm-linux/lib/libpthread.a
.PHONY : clean
clean:
rm -f $(EXEC) *.bin *.elf *.o *.s *.gdb *.bak *.*~
hello.c
#include <stdio.h>
int main(void)
{
int i;
for(i=0; i<101; i++)
{
printf("Hello world %d times!n", i);
}
}
0 意見:
張貼留言