Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何编写Makefile来链接C代码和Arm汇编代码?_C_Assembly_Makefile_Arm - Fatal编程技术网

如何编写Makefile来链接C代码和Arm汇编代码?

如何编写Makefile来链接C代码和Arm汇编代码?,c,assembly,makefile,arm,C,Assembly,Makefile,Arm,以下终端命令将在linux中编译和链接my.c和.s文件 rm *.o gcc -c printS.c -o printS.o as lab8.S -o lab8.o gcc lab8.o printS.o -o lab8test 我从来没有写过make文件,我觉得这样的东西值得一个。感谢您的帮助 与制作任何make文件的方式相同。我相信有很多例子和网页 ideally_the_result : dependencies <tab>the commands <tab>t

以下终端命令将在linux中编译和链接my.c和.s文件

rm *.o
gcc -c printS.c -o printS.o
as lab8.S -o lab8.o
gcc lab8.o printS.o -o lab8test

我从来没有写过make文件,我觉得这样的东西值得一个。感谢您的帮助

与制作任何make文件的方式相同。我相信有很多例子和网页

ideally_the_result : dependencies
<tab>the commands
<tab>the commands
<tab>the commands
并为您使用的每个命令制定规则。我建议您将最后一个放在第一位,这样如果make上没有命令行选项,它将是默认值

覆盖清理(使干净)的步骤


这是一个非常简单的方法。在此基础上,您可以深入研究各种特殊字符(使程序特定,gnu make vs others),这些字符意味着要制定更复杂的规则。

请看这个问题:这非常有用。这里有一些例子,但我不确定它在链接汇编文件时是否有不同的工作方式。把makefiles想象成与编译或链接无关,它只是一种用于运行程序的脚本语言。程序可以是任何东西,不必与工具链相关。可以让一个程序解析一个进行FFT的音频文件并创建一个gnuplot格式的数据文件,然后另一个规则获取该数据文件并调用gnuplot生成png。
printS.o : printS.c
    gcc -c printS.c -o printS.o
clean : 
   rm -f *.o
   rm -f lab8test