简体   繁体   English

MakeFile 不像可执行文件那样发光

[英]MakeFile is not glowing like it is Executable

This is the code that i have written in my makefile.这是我在 makefile 中编写的代码。 For some reason it is not letting me execute the make function.出于某种原因,它不允许我执行 make 函数。 When i type "make findName", i get "make: 'findName' is up to date."当我输入“make findName”时,我得到“make: 'findName' 是最新的。”

findName:       findName.cpp
        g++ -g findName.cpp -o findName;

clean:
        /bin/rm -f findName *.o

backup:
        #tar -zcvf bbrown.assignment4_1.tar.gz *.cpp *.h makeFile readme # will make a tar.gz
        tar -cvf bbrown.findName.tar *.cpp *.sh makeFile readme

A message like "make: 'target' is up to date."类似“make: 'target' 是最新的”这样的消息。 means that make has decided it doesn't need to run any commands, based on the timestamps of files involved.意味着make已经决定它不需要运行任何命令,基于所涉及文件的时间戳。 The make program considers files (and phony targets) to have a tree of prerequisites, and commands associated with creating a file will only be run if the file doesn't exist or has an older timestamp than one of its prerequisites. make程序认为文件(和虚假目标)具有先决条件树,并且只有在文件不存在或时间戳比其先决条件之一更旧时,才会运行与创建文件相关的命令。 In big projects, this helps avoid completely rebuilding everything which could take a lot of time, when only a few source files have actually changed: make will determine which commands are actually needed.在大型项目中,这有助于避免完全重建可能需要大量时间的所有内容,当只有少数源文件实际更改时: make将确定实际需要哪些命令。 But this does require setting up the Makefile with accurate prerequisites.但这确实需要使用准确的先决条件设置Makefile

Your Makefile specifies that file findName has one prerequisite: findName.cpp .您的Makefile指定文件findName有一个先决条件: findName.cpp If make successfully creates findName , then you do nothing else but just type make again, you'll see the "up to date" message: this is a feature.如果make成功创建了findName ,那么您什么都不make ,只需再次输入make ,您将看到“最新”消息:这是一项功能。 If you edit and save findName.cpp and then run make , it should repeat the g++ command.如果您编辑并保存findName.cpp然后运行make ,它应该重复g++命令。

But suppose you also have some header files you're including from findName.cpp , say findName.h .但是假设您还有一些来自findName.cpp头文件,比如findName.h If you edit and save findName.h and then run make , you'll get "up to date", since make didn't know to findName.h has effects on findName .如果您编辑并保存findName.h然后运行make ,您将获得“最新信息”,因为make不知道findName.hfindName You would need to add the prerequisite to fix this:您需要添加先决条件来解决此问题:

findName:       findName.cpp findName.h
        g++ -g findName.cpp -o findName

There are various ways to automatically deal with header dependencies like that, but they get into more advanced use of make , and/or using other build tools.有多种方法可以自动处理此类头文件依赖项,但它们更高级地使用make和/或使用其他构建工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM