造成文件错误请指导 [英] Make file error please guide
问题描述
我有这样的文件/文件夹结构
我的文件夹包含
main.c
然后我的文件夹包含另外两个名为source和header的文件夹
main.c引用了header中的头文件文件夹。
* .c源文件(位于源目录中)在header目录中有头文件。
所以我写了这样的make文件
I am having a file/folder structure like this
"MY" folder contain
main.c
then "My" folder contain two other folders named "source" and "header"
main.c has references to header files that are in the "header" folder.
The *.c source files (that are in the source directory) has there header files in "header" directory.
So i have written the make files like this
program: main.o CPU.o OS.o RAM.o snmputil.o UTILITY_FUNCTION.o
main.o: main.c /header/OS.h /header/snmputil.h /header/CPU.h
gcc -o main.c
CPU.o: /source/CPU.c ../header/CPU.h
gcc -o /source/CPU.c
OS.o: OS.c ../header/OS.h
gcc -c /source/OS.c
UTILITY_FUNCTION.o: /source/UTILITY_FUNCTION.c ../header/UTILITY_FUNCTION.h
gcc -c /source/UTILITY_FUNCTION.c
当我在makefile上制作时我得到错误
when i do make on the makefile i get the error
missing separator. Stop.
请指导
Please guide
推荐答案
main.o:main.c /header/OS.h /header/snmputil.h /header/CPU.h
gcc -o main.c
main.o: main.c /header/OS.h /header/snmputil.h /header/CPU.h
gcc -o main.c
应该是:
Should be:
main.o: main.c header/OS.h header/snmputil.h header/CPU.h
gcc -I header -c main.c
CPU.o:/source/CPU.c ../header/CPU.h
gcc -o /source/CPU.c
CPU.o: /source/CPU.c ../header/CPU.h
gcc -o /source/CPU.c
应该是:
Should be:
CPU.o: ../source/CPU.c ../header/CPU.h
gcc -I../header -c /source/CPU.c
等等。
此外,在编译指令之前,请确保您(以及您的编辑器)使用 tabs
而不是 blanks
(即在 gcc
之前)。
and so on.
Moreover, make sure you (and your editor as well) are using tabs
instead of blanks
, before compiling directives (i.e. before gcc
).
这篇关于造成文件错误请指导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!