The object binary file changes in each assembly

When compiling using the g ++ GNU compiler, every time I make an assembly, without changing the source code, I get another binary of the object. Is there a compilation option that will give me the same binary every time.

+5
source share
2 answers

Copied from the GCC man page:

-frandom-Seed = string
This parameter provides the seed that GCC uses, if you use random numbers otherwise. this is used to generate specific symbol names, which must be different in each compiled file. It is also used to place unique stamps in coverage data files and object files that produce them. You can use the -frandom-seed option to create reproducible, identical object files.

The line should be different for each file that you compile.

+10
source

You better use make. Thus, if your source has not changed, the compilation will be skipped, so the object files will not be changed.

: , make , . .

makefile:

all: source

source: source.i.cpp
    @cmp -s source.i.cpp source.i.prev || g++ source.i.cpp -o source
    @touch source
    @cp source.i.cpp source.i.prev

source.i.cpp: source.cpp
    @g++ -E source.cpp >source.i.cpp

, , ( , ).

0

All Articles