sxwglxq 发表于 2005-10-26 10:30:01

如何单独编译应用程序?

uclinux支持FTP,我想单独编译应用程序(不编译内核),然后通过ftp传到sdram上运行.
我的Makefile文件:
CC = arm-elf-gcc
EXEC = server
OBJS = server.o
#CFLAGS += -I.

all: $(EXEC)

$(EXEC): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

romfs:
        $(ROMFSINST) /bin/$(EXEC)

clean:
        -rm -f $(EXEC) *.elf *.gdb *.o
然后make:
# make
arm-elf-gcc-o server server.o
/usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o): In function `__do_global_ctors':
__main.o(.text+0xc4): undefined reference to `__CTOR_LIST__'
/usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.data+0x0): undefined reference to `__DTOR_LIST__'
collect2: ld returned 1 exit status
make: *** Error 1
或者:
# arm-elf-gcc -I /usr/include/ server.c
/tmp/ccQjsEGJ.o: In function `main':
/tmp/ccQjsEGJ.o(.text+0x12c): undefined reference to `htonl'
/tmp/ccQjsEGJ.o(.text+0x144): undefined reference to `htons'
/usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o): In function `__do_global_ctors':
__main.o(.text+0xc4): undefined reference to `__CTOR_LIST__'
/usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.data+0x0): undefined reference to `__DTOR_LIST__'
collect2: ld returned 1 exit status
哪位大牛知道是什么原因吗?先谢了.

rootlinger 发表于 2005-10-26 11:13:24

你可以先用 gcc编译,看通过不, 然后在考虑用arm-elf-gcc :oops:

sxwglxq 发表于 2005-10-26 11:45:18

用Gcc没问题,在PC上运行的很好.但是用GCC编译的可执行文件在板子上不能运行.

rootlinger 发表于 2005-10-26 14:30:25

:oops:

lumit-support-1 发表于 2005-10-26 15:37:56

$(LDLIBS)怎么没有定义啊?
最好先编一个helloworld试一下你的交叉编译工具是否可用!!

sxwglxq 发表于 2005-10-26 16:37:03

# arm-elf-gcc -I /usr/include/ -o server server.c
/opt/uClinux/arm-elf/bin/gld: cannot open crt0.o: ?????????
collect2: ld returned 1 exit status
编译环境应该是好的,添加了应用程序的内核能编译运行.
uClinux开发包里LDLIBS在哪个文件里定义?

rootlinger 发表于 2005-10-26 18:25:49

其实,有个最笨的方法,你可以把应用程序和内核一起编译,编译完成后在/romfs/bin/目录下,找到你编译的可执行文件,把它单独放到板子上,肯定是可以运行的, :lol::lol:

rootlinger 发表于 2005-10-26 18:26:45

欧,是单独通过ftp放到SDRAM 中,改变执行属性,就可以执行了 :oops:

lumit-support-1 发表于 2005-10-26 22:18:08

编译环境应该是好的,添加了应用程序的内核能编译运行.

最好能拷一个带Makefile和应用程序的文件夹,然后替换成自己的应用程序,并修改Makefile的相关文件名。然后make应该不回有问题吧!!!
还是不行的话,自己写一个hello程序,然后手动编译它!!试一下!
页: [1]
查看完整版本: 如何单独编译应用程序?