您的位置:首页 > 运维架构 > Linux

关于Makefile的正确使用

2016-03-24 12:08 513 查看


最近遇到这样脑缠问题,在纠结中;其实就是没有弄清楚原理:

#Makefile Example

test :hello.o test1.o test2.o

        gcc -o test hello.o test1.o test2.o

hello.o :hello.c  head1.h  head2.h

        gcc -c hello.c

test1.o :test1.c head1.h

        gcc -c test1.c

test2.o :test2.c head2.h

        gcc -c test2.c

install:

        cp test/home/temp

clean:

        rm -f*.o

~                                                                           

~                                                                           

~            

这样用gcc编译的,只能在windows环境下运行,而不能在ARM下运行

也不能用arm-linux-gcc 编译(最近就是犯了大错,在这里纠结,现在才知道原理)

若想要在arm环境下运行,在makefile中把gcc 改为arm-linux-gcc,这样就可以在arm中运行了

#Makefile Example

test :hello.o test1.o test2.o

        arm-linux-gcc -o test hello.o test1.o test2.o

hello.o :hello.c  head1.h  head2.h

        arm-linux-gcc -c hello.c

test1.o :test1.c head1.h

        arm-linux-gcc -c test1.c

test2.o :test2.c head2.h

        arm-linmux-gcc -c test2.c

install:

        cp test/home/temp

clean:

        rm -f*.o

原创,希望对大几有用。   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息