Peter Lee
Peter Lee

Reputation: 13809

Same simple source code, different binaries on Windows

I have a question about the source-code binary on Windows.

#include <stdio.h>

int main()
{
    printf("Hello, world!\n");

    return 0;
}

The same source code, I compiled twice on Windows (VS 2008 Cmmand Prompt: "CL"), but I got different binaries.

cl new.cpp

Can you guys tell me why, and how to avoid that?

Upvotes: 5

Views: 1304

Answers (3)

Peter Lee
Peter Lee

Reputation: 13809

I googled, and found a mid-way solution:

DUMPBIN  /RAWDATA  MyApp.EXE > first.txt
DUMPBIN  /RAWDATA  MyApp.EXE > second.txt

http://support.microsoft.com/kb/164151 How to compare binary images of the same project builds

Upvotes: 1

josuegomes
josuegomes

Reputation: 501

The timestamp is part of PE format. You'll always get different values regardless if compiling as release or not.

Upvotes: 4

Michael Dorgan
Michael Dorgan

Reputation: 12515

Did you compile as release? Debug has timestamps built in which can change your exe per compile

Upvotes: 1

Related Questions