Click to See Complete Forum and Search --> : Object file size different for same source code?
scorpicorn
February 24th, 2003, 07:56 PM
I have 2 directories having the same set of C source codes.
I ran the same makefile to compile the source to object files in both directories. However the two copies of .obj file generated have different sizes!
Since the .obj are subseqently linked into library files, it made the two libraries to differ in size too.
Just want to confirm that both libraries have identical functionality even though they have different size. Any idea?
eug_prog
March 11th, 2003, 04:53 PM
Are these directories in different partitions with differing file systems?
If file systems are not identical, that would account for differences in size.
Another thing could be that some options for liking are different in the makefiles, unless these makefiles are identical, of course.
Also, you might have a global variable responsible for setting up build area with debug information (in addition to your compiler options). Even that variable might make a difference.
Or, it could be as simple as that one of your builds was not entirely succesfull.
scorpicorn
March 12th, 2003, 12:13 AM
Thanks for the reply.
I tried compiling the same source codes on a few different directories in the SunOS 5.8 machine.
The files I have are located as follows:
$HOME/csrc/test.c
$HOME/csrc/test.h
$HOME/csrc/include/test.h
$HOME/include/test.h
Note that the test.h header files are identical.
Next I run following gcc command successfully noting down the generated obj file test.o each time. The result was all 3 obj differs by a few bytes.
gcc -g2 -DDEBUG -c -o test.o test.c
gcc -g2 -DDEBUG -c -I./include -o test.o test.c
gcc -g2 -DDEBUG -c -I../include -o test.o test.c
Doing the little experiment, I guess the file size is not an issue. I have even created copies of shared library .so from the different .o and used it without running into errors.
eug_prog
March 12th, 2003, 04:50 PM
This is, indeed, strange. Since I don't know how different the sizes are for your test.o files, the only thing I could think of is that the include option for test.h for gcc is the one responsible here.
Basically, -I option is translated into object code, which may slightly differ in size, as a result. I have seen that happening, but it is more of an issue in Windows than in Unix; at least, I thought so...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.