[vox-tech] gcc easy question

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Jan 30 12:42:11 PST 2006


Alex Mandel wrote:
> Jeff Newmiller wrote:
> 
>> Alex Mandel wrote:
>>
>>> So I'm trying to learn how to compile things for distribution and had 
>>> an  easy question.
>>> 1. When I use gcc how do I tell it to output the files to a separate 
>>> directory so that I have just the libraries and executables I need 
>>> for distribution.
>>
>>
>> see the "-o" option for gcc.  Just specify a relative directory name as
>> part of the destination filename.
> 
> I guess what I'm confused about it that I'm running.
> $./configure
> $make
> I know it uses gcc but I'm not calling it explicitly so I can' seem 
> where to fit the -o option in.
> Should I be using $gcc ?

No.

Your original question led me to beleive that you had written a program
in C and were trying to figure out how to setup a make file that would
cleanly create the final installation files.

Given that you are trying to understand how an existing source
distribution works, I can think of two responses:

a) the "convention" is to "./configure ; make ; make install".  Most people
just do it and get on with life.

b) Picking and choosing files from the output of the build process
is something that you can normally only do if you know how the build works.
This is doable, but there can be quite a lot of "assumed knowledge"
in open source build processes.  For example, "./configure" is a shell
script to create a makefile customized for compiling that software
package on your operating system.  For example, this means that in
some cases it will accept an option as to where to put the final
files when "make install" is executed, so you can customize the installation
at a high level.  If you can follow shell script and makefiles, you
can read the configure script and the generated makefile to figure
out where things are going.

> 
>>> 2. Will it output only what I need or will there be a bunch of 
>>> intermediate files too that I could skip for the distribution.
>>
>>
>> While is is possible to compile and link from source to executable
>> in one step, it isn't very common for medium to large-scale programs
>> because the all-in-one compilation slows the development cycle down.
>> For this reason, many makefile authors put in a "clean" virtual target
>> to delete temporary files.
>>
>> You might find reading [1] and [2] helpful... in particular the link to
>> "Makefile Conventions" in the latter.
>>
>> [1] http://en.wikipedia.org/wiki/Make
>> [2] http://www.gnu.org/software/make/
>>
> As you can see from the above commands, maybe it's not one step. I need 
> the results of make to end up in a directory on its own. Right now I'm 
> using a diff program to extract new files that didn't exist in the 
> source files but this gets me a lot of files, a ton with the .lo 
> extension and I'm not sure I need these for the one component I need to 
> run.

I advise building, installing, and using the package as a whole, rather
than picking and choosing pieces.  If you really need to pick and
choose, then you may have to learn rather more about how it is
constructed than you thought you would... a process that can take months
rather than minutes.

-- 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------


More information about the vox-tech mailing list