初回投稿 : 2011-06-09 00:06:27
ターゲットで Hello World
■ホストで実行
# mkdir /opt/uClinux-dist/myapp
# cd /opt/uClinux-dist/myapp
# vi hello.c
---
#include <stdio.h>
int main(void)
{
printf("Hello, uClinux/H8!!(^o^)/\n");
return 0;
}
---
# vi makefile
---
TARGET=hello
SRCS=hello.c
CC=h8300-linux-elf-gcc
CFLAGS=-mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc
LDFLAGS=-Wl,-elf2flt
STARTUP=../lib/crt0.o
INCLUDES=-I../include -I../include/include
LIBS=-L../lib -lc
OBJS=$(SRCS:.c=.o)
.c.o :
$(CC) $(CFLAGS) $(INCLUDES) $(SRCS) -c $<
$(TARGET) : $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $(STARTUP) $(LIBS) $(OBJS) -o $(TARGET)
---
# make
h8300-linux-elf-gcc -mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc -I../include -I../include/include hello.c -c hello.c
hello.c:6:2: warning: no newline at end of file
hello.c:6:2: warning: no newline at end of file
h8300-linux-elf-gcc -mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc -I../include -I../include/include -Wl,-elf2flt ../lib/crt0.o -L../lib -lc hello.o -o hello
# cp hello /tftpboot/nfsroot/bin
■ターゲットで実行
# cd bin
# hello
Hello, uClinux/H8!!(^o^)/
#
ターゲットで Hello World
■ホストで実行
# mkdir /opt/uClinux-dist/myapp
# cd /opt/uClinux-dist/myapp
# vi hello.c
---
#include <stdio.h>
int main(void)
{
printf("Hello, uClinux/H8!!(^o^)/\n");
return 0;
}
---
# vi makefile
---
TARGET=hello
SRCS=hello.c
CC=h8300-linux-elf-gcc
CFLAGS=-mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc
LDFLAGS=-Wl,-elf2flt
STARTUP=../lib/crt0.o
INCLUDES=-I../include -I../include/include
LIBS=-L../lib -lc
OBJS=$(SRCS:.c=.o)
.c.o :
$(CC) $(CFLAGS) $(INCLUDES) $(SRCS) -c $<
$(TARGET) : $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $(STARTUP) $(LIBS) $(OBJS) -o $(TARGET)
---
# make
h8300-linux-elf-gcc -mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc -I../include -I../include/include hello.c -c hello.c
hello.c:6:2: warning: no newline at end of file
hello.c:6:2: warning: no newline at end of file
h8300-linux-elf-gcc -mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc -I../include -I../include/include -Wl,-elf2flt ../lib/crt0.o -L../lib -lc hello.o -o hello
# cp hello /tftpboot/nfsroot/bin
■ターゲットで実行
# cd bin
# hello
Hello, uClinux/H8!!(^o^)/
#