日期:2014-05-16  浏览次数:20663 次

makefile 问题
各位大大,刚学着写makefile,内容如下。在运行make test的时候,出现一个问题,求指导

CC=gcc

run:
@$(CC) -O -c -fPIC -o keyu.o keyu.c
@$(CC) -shared -o libkeyu.so keyu.o
@#build shared lib
@cp libkeyu.so /usr/local/lib
@echo /usr/local/lib > /etc/ld.so.conf.d/local.conf 
@/sbin/ldconfig
@#load shared lib

test:
@$(CC) -O -c -fPIC -o keyu.o keyu.c
@$(CC) -shared -o libkeyu.so keyu.o
@#build shared lib
@cp libkeyu.so /usr/local/lib
@echo /usr/local/lib > /etc/ld.so.conf.d/local.conf 
@#load shared lib
@gcc -o test01 -lkeyu test01.c
@./test01
@#run test01

.PHONY: clean
clean:
rm -f test01 keyu.o libkeyu,so
运行结果如下:
[root@localhost keyu_C]# make test
//test01的内容=>
Data before encrypt is:41 42 43 0 0 0 0 0 0 0 0 0 0 0 0 0 
data after encrypt is:
0x31 0x9b 0x74 0x81 0xde 0xf3 0xd5 0x49 0x3b 0x28 0xf4 0xae 0xe9 0 0xaf 0xf1 
0x31 0x9b 0x74 0x81 0xde 0xf3 0xd5 0x49 0x3b 0x28 0xf4 0xae 0xe9 0 0xaf 0xf1 
data after decrypt is:
0x41 0x42 0x43 0 0 0 0 0 0 0 0 0 0 0 0 0 
//<====test01内容
make: *** [test] 错误 10

请问最后一行,错误10是指的什么呀(我在终端运行./test01就不会出现这个问题诶)

------解决方案--------------------
不太懂
------解决方案--------------------
楼主为何要在Makefile中运行程序呢?

Makefile的任务是产生可执行程序,如果你的程序执行有问题,就应该从源代码上找问题。
------解决方案--------------------
探讨

引用:
程序test01的返回值是什么?

test01 无返回值,void