首页 \ 问答 \ GNU不删除中间文件(GNU make Not Deleting Intermediate Files)

GNU不删除中间文件(GNU make Not Deleting Intermediate Files)

我的makefile如下:

# The names of targets that can be built.  Used in the list of valid targets when no target is specified, and when building all targets.
TARGETS := libAurora.a libAurora.so

# The place to put the finished binaries.
TARGET_DIRECTORY := ./Binaries

# The compiler to use to compile the source code into object files.
COMPILER := g++

# Used when compiling source files into object files.
COMPILER_OPTIONS := -I. -Wall -Wextra -fPIC -g -O4

# The archiver to use to consolidate the object files into one library.
ARCHIVER := ar

# Options to be passed to the archiver.
ARCHIVER_OPTIONS := -r -c -s

SOURCE_FILES := $(shell find Source -type f -name *.cpp)
OBJECT_FILES := $(SOURCE_FILES:.cpp=.o)

.PHONY: Default # The default target, which gives instructions, can be called regardless of whether or not files need to be updated.
.INTERMEDIATE: $(OBJECT_FILES) # Specifying the object files as intermediates deletes them automatically after the build process.

Default:
    @echo "Please specify a target, or use \"All\" to build all targets.  Valid targets:"
    @echo "$(TARGETS)"

All: $(TARGETS)

lib%.a: $(OBJECT_FILES)
    $(ARCHIVER) $(ARCHIVER_OPTIONS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)

lib%.so: $(OBJECT_FILES)
    $(ARCHIVER) $(ARCHIVER_OPTIONS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)  

%.o:
    $(COMPILER) $(COMPILER_OPTIONS) -c -o $@ $*.cpp

如您所见, .o文件通过.INTERMEDIATE目标指定为中间体。 但是,在编译完成后,它们不会按预期删除。 相反,它们仍然保留在创建它们的位置,使我的源目录变得混乱。

奇怪的是它在另一台机器上完美运行。 这让我相信它是一个不同版本的make ,但man make仍然将它显示为“GNU make utility”。

为什么不删除中间文件?

编辑: make -v报告版本3.81。

编辑:手动删除.o文件(即一个干净的平板)后, make All产生以下输出:

g++ -I. -Wall -Wextra -fPIC -g -O4 -c -o Source/File/File.o Source/File/File.cpp
g++ -I. -Wall -Wextra -fPIC -g -O4 -c -o Source/Timer/Timer.o Source/Timer/Timer.cpp
ar -r -c -s ./Binaries/libAurora.a Source/File/File.o Source/Timer/Timer.o
ar -r -c -s ./Binaries/libAurora.so Source/File/File.o Source/Timer/Timer.o

My makefile is as follows:

# The names of targets that can be built.  Used in the list of valid targets when no target is specified, and when building all targets.
TARGETS := libAurora.a libAurora.so

# The place to put the finished binaries.
TARGET_DIRECTORY := ./Binaries

# The compiler to use to compile the source code into object files.
COMPILER := g++

# Used when compiling source files into object files.
COMPILER_OPTIONS := -I. -Wall -Wextra -fPIC -g -O4

# The archiver to use to consolidate the object files into one library.
ARCHIVER := ar

# Options to be passed to the archiver.
ARCHIVER_OPTIONS := -r -c -s

SOURCE_FILES := $(shell find Source -type f -name *.cpp)
OBJECT_FILES := $(SOURCE_FILES:.cpp=.o)

.PHONY: Default # The default target, which gives instructions, can be called regardless of whether or not files need to be updated.
.INTERMEDIATE: $(OBJECT_FILES) # Specifying the object files as intermediates deletes them automatically after the build process.

Default:
    @echo "Please specify a target, or use \"All\" to build all targets.  Valid targets:"
    @echo "$(TARGETS)"

All: $(TARGETS)

lib%.a: $(OBJECT_FILES)
    $(ARCHIVER) $(ARCHIVER_OPTIONS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)

lib%.so: $(OBJECT_FILES)
    $(ARCHIVER) $(ARCHIVER_OPTIONS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)  

%.o:
    $(COMPILER) $(COMPILER_OPTIONS) -c -o $@ $*.cpp

As you can see, the .o files are specified as intermediates via the .INTERMEDIATE target. However, they are not deleted as expected after compilation finishes. Instead, they remain where they were created, cluttering up my source directory.

The strange thing is that it works perfectly on another machine. This leads me to believe it's a different version of make, but man make still shows it as the "GNU make utility."

Why won't make delete the intermediate files?

EDIT: make -v reports version 3.81.

EDIT: After manually deleting the .o files (i.e., a clean slate), make All produces the following output:

g++ -I. -Wall -Wextra -fPIC -g -O4 -c -o Source/File/File.o Source/File/File.cpp
g++ -I. -Wall -Wextra -fPIC -g -O4 -c -o Source/Timer/Timer.o Source/Timer/Timer.cpp
ar -r -c -s ./Binaries/libAurora.a Source/File/File.o Source/Timer/Timer.o
ar -r -c -s ./Binaries/libAurora.so Source/File/File.o Source/Timer/Timer.o

原文:https://stackoverflow.com/questions/6512914
更新时间:2022-08-10 07:08

最满意答案

问题是您在多个来源的IDENTITY字段中生成记录,然后无法在没有为这些记录分配新的IDENTITY值的情况下将它们组合在一起。

通过使用GUID作为关键字段,3个数据库中的每个数据库都可以创建具有唯一ID的记录,然后您就可以毫无问题地将它们组合在一起。 您仍然可以在该字段上具有UNIQUE约束,但生成相同GUID的可能性在天文数字上很小。

大多数复制过程已经在某种程度上使用了这种GUID方法,因此它是解决此问题的常见方法。


The problem is that you're generating records in an IDENTITY field in multiple sources, then unable to combine them without those records being assigned new IDENTITY values.

By using a GUID as your key field, each of the 3 databases can create records which will have a unique ID, and you'll be able to then combine them without issue. You can still have a UNIQUE constraint on the field, but the likelihood of generating the same GUID is astronomically small.

Most replication processes utilize this GUID approach at some level already, so it's a common solution to this problem.

相关问答

更多
  • ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE} [WITH VALUES] Syntax: ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VA ...
  • 您必须使用WITH VALUES来获取值而不是null。 2016年使用WideWorldImporters: ALTER TABLE sales.orders ADD c1 INT DEFAULT 10 WITH VALUES GO You have to use WITH VALUES to get the value and not the null. Using WideWorldImporters on 2016: ALTER TABLE sales.orders ADD c1 INT D ...
  • 对于此insert : INSERT INTO tblPlayerGame (PlayerOneScore,PlayerTwoScore) VALUES (22,19); 您没有PlayerId和GameId值。 这些被声明为NOT NULL ,没有默认值。 因此,您收到错误。 For this insert: INSERT INTO tblPlayerGame (PlayerOneScore,PlayerTwoScore) VALUES (22,19); You have no val ...
  • 你是对的。 声明列not null时,不需要默认定义。 如果您查看create table的语法图,这一点非常明显: ::= column_name . . . [ CONSTRAINT constraint_name [ DEFAULT constant_expression ] ] . . . [ NULL | NOT NULL ] 如果需要的语法,它看起来更像这样:
  • 问题是您在多个来源的IDENTITY字段中生成记录,然后无法在没有为这些记录分配新的IDENTITY值的情况下将它们组合在一起。 通过使用GUID作为关键字段,3个数据库中的每个数据库都可以创建具有唯一ID的记录,然后您就可以毫无问题地将它们组合在一起。 您仍然可以在该字段上具有UNIQUE约束,但生成相同GUID的可能性在天文数字上很小。 大多数复制过程已经在某种程度上使用了这种GUID方法,因此它是解决此问题的常见方法。 The problem is that you're generating rec ...
  • select id, 0 as value_default from myTable 所以您有一个初始默认值分配给一个命名列(您可以更改的值)。 select id, 0 as value_default from myTable so you have an initial default value assigned against a named column (the value of which you can change).
  • 您应该为该函数添加模式名称: CREATE TABLE [dbo].[Clients]( [ModifyingUser] [nvarchar](128) NOT NULL DEFAULT dbo.sCurrentAppUser (), [Modification] [char](1) NULL DEFAULT 'A', [ModifyingHost] [nvarchar](128) NOT NULL DEFAULT host_name (), [ClientID] [uniqueid ...
  • 我看到的最简单的方法是使用UDF(用户定义函数)检查约束。 比如说,看看这里。 http://sqljourney.wordpress.com/2010/06/25/check-constraint-with-user-defined-function-in-sql-server/ 未经测试的例子 CREATE FUNCTION dbo.CheckDefaultUnicity(@UserId int) RETURNS int AS BEGIN DECLARE @retval int SELEC ...
  • 因为您已在该列上设置了GetDate() ,并且您已指定该列的默认值是当前日期GetDate() because you have set a contraint on that column and you have specified that a default value on that column is the current date GetDate()
  • 您可以使用INSTEAD OF INSERT触发器来设置它,或者您可以将第二列设置为计算列,并将值设置为第一列的值。 您可以尝试将第二列的默认值设置为第一列的值,但我不确定它是否会在设置第二列之前等待第一列的设置,或者在应用值之前是否将它设置为NULL到第一个。 You can use an INSTEAD OF INSERT trigger to set it, or you can have the second column be a computed column and set the value ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)