2012-11-25 76 views
0

我正在使用this generic makefileMakefile错误:缺少分隔符,使用SDL和OpenGL编译

与此自定义的选项:而不是

# The pre-processor options used by the cpp (man cpp for more). 
CPPFLAGS = -Wall -I/Library/Frameworks/SDL.framework/Headers 

# The options used in linking as well as in any direct use of ld. 
LDFLAGS = -framework SDL -framework Cocoa -framework OpenGL 

# The executable file name. 
# If not specified, current directory name or `a.out' will be used. 
PROGRAM = app 

# The source file types (headers excluded). 
# .c indicates C source files, and others C++ ones. 
SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp .m 

clean: 
    $(RM) $(OBJS) $(PROGRAM) $(PROGRAM) 

# The pre-processor options used by the cpp (man cpp for more). 
CPPFLAGS = -Wall 

# The options used in linking as well as in any direct use of ld. 
LDFLAGS = 

# The executable file name. 
# If not specified, current directory name or `a.out' will be used. 
PROGRAM = 

# The source file types (headers excluded). 
# .c indicates C source files, and others C++ ones. 
SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp 

clean: 
    $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe 

Here你可以找到我运行生成文件的完整版本。

我使用Mac OS X 10.6.8和gcc 4.2.1,并尝试使用SDL和OpenGL编译main.cppSDLMain.mSDLMain.h

弹出的错误是:

main.d:1: * missing separator. Stop.

和文件main.d(由生成的makefile)是这样的:

-n ./ 
main.o: main.cpp 

什么问题?

+0

你在这里表现出整个文件?因为我没有看到一个'include'行,但它正在抱怨单独文件('main.d')的内容。 * //读取错误信息:这就是你所做的。* – dmckee

+0

@dmckee [This](http://pastebin.com/fqXxDesJ)是该文件的完整粘贴。 (注意我的问题的第一行)。 – Shoe

+1

*“(另请注意,我的问题的第一行)”*我不读代码的网站:你的问题应该站在它自己的。特别是,如果要点击几次甚至可以看到它,我尤其不会阅读代码。你对现有的依赖文件('.d's)有问题。清除它们,看看它是否再次出现。 – dmckee

回答

0

我换成echo -nprintf,它解决了这个问题:

# Rules for creating dependency files (.d). 
#------------------------------------------ 

%.d:%.c 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.C 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.cc 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.cpp 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.CPP 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.c++ 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.cp 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.cxx 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 

%.d:%.m 
    @printf $(dir $<) > [email protected] 
    @$(DEPEND.d) $< >> [email protected] 
+0

这些行实际上*做*有道理!没有它们的依赖不会正确处理子目录中的文件。问题是使用'echo'(可能是你的设置中的'make'使用的shell中的一个):它不理解'-n'选项,它应该在'echo'结尾压制换行符'' s产量。 –

+0

@DietmarKühl,'printf'的工作原理是什么? – Shoe

+0

是的,我认为是。显然,你不会使用'-n'选项,而是忽略格式中的任何换行符。然而,我不认为'printf'是一个标准的POSIX shell命令,这可能是'echo'被使用的原因(虽然我不确定'-n'选项是否标准;我不认为它是)。 –

1

您显示的Makefile [exerpt]不显示main.d的创建方式,但它似乎包含在实际的Makefile中。它可能意味着包含main.cpp的依赖关系,但包含-n ./' is clearly not valid make`语法。尝试现在删除文件,如果它被重新生成,你需要找到它是如何生成的,并解决这个问题。看看它是如何再次产生删除该文件,并使用

make -p 2>&1 | tee mkerr 

一旦完成,mkerr包含make命令的输出,包括它使用的规则。有一个规则是如何构建.d文件。随着一点点运气,删除文件排序问题...

基于发布到pastebin该问题的代码是如何%.d文件被创建的规则:

%.d: %.cpp 
    @echo -n $(dir $<) > [email protected] 
    @$(DEPEND.d) $< << [email protected] 

的问题是,发现的echo不理解-n选项,该选项旨在避免任何换行符。规则的第一行应该为文件添加一个目录前缀。 esieast修复是找到更好的echo,它理解-n选项。虽然,您可能需要使用不同的外壳,因为echo往往是内置的外壳!在这种情况下,您可能最好使用echo上的完整路径指向不会出现错误的版本。

+0

我尝试删除'.d'文件并再次运行'make',它仍然会再次创建它。完整的文件请看[这里](http://pastebin.com/fqXxDesJ)。 – Shoe

+0

@Jeffrey:你是否用'-p'选项运行以查看完整的规则集? –

+0

我刚刚试过运行'make -p'并打印makefile。它是用'-n。/'做什么的? '-n'标志的含义是什么? (I [试图](http://www.google.it/#hl=it&gs_nf=3&qe=LW4gZmxhZyBtYWtlZmlsZQ&qesig=uTjr2lI3792UCBsMoSjm4w&pkc=AFgZ2tmFXf6nSo26tlvpJYJnXI9bs3B1jRth0p83G1N91Cq_0m0Wb7Aib28tARcz3WPTC0w01iJutlEyqHChVAaCnRy786QRtQ&pq=gcc%20flags&cp=16&gs_id=5g&xhr=t&q=-n+flag+makefile&pf=p&tbo=d&sclient= psy-ab&oq = -n + flag + makefile&gs_l =&pbx = 1&bav = on.2,or.r_gc.r_pw.r_cp.r_qf。&fp = 70759a6a8974c64e&bpcl = 38897761&biw = 1279&bih = 680)和[试用](http:// tigcc。 ticalc.org/doc/comopts.html)用Google搜索它) – Shoe