且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

比较相同源代码的二进制文件

更新时间:2023-11-15 23:11:04

如果您仔细地遵循了该页面上的步骤,并且二进制文件满足了该步骤的要求(例如必须是Release版本),那么该过程应该足以告诉您基础图像是否相同.

Provided you follow the procedure carefully on that page, and the binaries satisfy the procedure's requirements (e.g. must be a Release build), that procedure should be enough to tell you whether the underlying images are the same. 

但是,这不能保证它们是从相同的源代码构建的!可能(尽管不太可能)两个略有不同的源代码版本可以编译为相同的目标代码.

This does not guarantee that they were built from the same source code, however!  It is possible (although unlikely) that two slightly different versions of the source code can compile to the same object code.

另请参阅该页面上的注释

See also the note on that page which says

注意:不能保证Visual C ++在连续构建中构建相同的源文件时将生成相同的二进制映像.

NOTE: There is no guarantee that Visual C++ will generate the same binary image when building the same source files on successive builds.

确保两个内部版本具有相同源代码的常用方法是使用版本控制工具(或更普遍地,使用软件配置管理(SCM)工具)来存储和标记与之对应的一组特定的源构建. 要正确执行此操作,您必须确保构建构建所需的一切-可以在完全不同的计算机上复制,包括库,可执行文件和构建脚本.

The usual approach to guaranteeing that two builds have the same source code is by using a Revision Control tool (or more generally, a Software Configuration Management (SCM) tool) to store and label a specific set of sources corresponding to a build.  To do this properly, you have to make sure that everything that goes into constructing a build - including libraries, executables, build scripts can be reproduced on a completely different machine.