just a question about what happens to the source files when you compile them

Don's LFS dss-lfs at cfl.rr.com
Thu Feb 27 06:08:48 PST 2003


On Thursday, February 27, 2003, at 04:30  AM, Florian Teply wrote:

> Matthijs wrote:
>> Hi everyone,
>> I was just wondering what happens to the source files
>> when you compile them, why do they get that big (as in
>> harddisk space)? For instance, after the compilation
>> of Xfree68 the source in the /usr/src/xc directory is
>> much larger as it was before you compiled it. But
>> after the compilation you can erase all that stuff
>> (right?). Thats why I would like to know why the
>> source gets that big, probably not to just get wiped
>> out after compilation. This also goes for the kernel
>> sources and for every other program as well, altough
>> the source of Xfree68 really got very large...
>> Hopefully somebody knows around here, I could not find
>> it on google...
> Obviously i´m not a pro in this art, but if i remember correctly, 
> executing the Makefiles produces a kind of snapshot of the current 
> system. Along with probably some binaries, this could possibly grow 
> large...
> People out there, correct me if i´m wrong...
>
> Grets Florian
>

What happens is the text source is read by the compiler to produce what 
is called object code (hence the .o extension on these files). These 
contain binary machine readable code AKA processor instructions. They 
also contain references to other pieces of object code, either in other 
.o files or libraries, which are just collections of object files. 
Finally the linker (ld) reads all these object files and libraries 
together to produce an executable, things like xterm, that can actually 
be run.

All of the stuff is built in place, i.e. in the source directory, when 
you issue the make command. That is why this directory becomes so 
large. When you say 'make install' the executables are copied into 
their ultimate destination, wherever you specified with the configure 
command. After "make install' you can safely delete the source 
directories because you've made a copy of everything built in the 
proper directories for running them.

Also, programs like bison/yacc and (f)lex are designed to produce 
source code (among other things) from scripts, so yes, source is 
sometimes produced during the make.

I hope I was able to explain it satisfactorily to you.
-- 
Don

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-chat' in the subject header of the message



More information about the lfs-chat mailing list