Embedded Program Example: Compiling Your Application into uCLinux
This article takes an example to illustrate the procedures to write an application and compile it into the uCLinux filesystem.
(OS_HOME refers to your root directory of the uCLinux)
Step1: Write your own source code
Applications in uCLinux are usually located in the directory ‟OS_HOME/user‟. Create a directory ‟Hello‟ in the ‟OS_HOME/user‟ and then a file Hello.c in the directory ‟OS_HOME/user/Hello‟, input the code below:
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
An application, namly the "Hello World" will be created.
Step2, edit the Makefile for the "Hello world" application.
Makefile
--------------------------------------------------------------------------------------------
#########################################################
# uclinux project type.
#########################################################
EXEC = Hello
OBJS = Hello.o
CFLAGS += -I.
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
romfs:
$(ROMFSINST) /bin/$(EXEC)
clean:
-rm -f $(EXEC) *.elf *.gdb *.o
--------------------------------------------------------------------------------------------
