92Chapter3 • Compilers and Assemblers
[root@conformix /opt]# make LDFLAGS=-all-static tooldir=/opt/
gcc-3.0.4
[root@conformix /opt]# make tooldir=/opt/gcc-3.0.4 install
Note that since we have used
/opt/gcc/3.0.4
as a prefix and
tooldir
as the desti-
nation for installation, the binary utilities will be installed in
/opt/gcc-3.0.4/bin
direc-
tory. As you may have noted, I have installed all software under
/opt/gcc-3.0.4
so that I
can use one directory for all of my tools.
3.6Handling Warning and Error messages
The GNU compiler generates two types of messages when compiling source code. Warning
messages are non-critical messages and the compiler can build the output code even if there are
warning messages. Error messages are fatal messages and compiler is not able to generate out-
put files when an error occurs. By default, the compiler does not display many warning mes-
sages. You may like to see these messages, for example, when you want to get a release of a
software package. Usually the release version of software should be compiled without any warn-
ing message. Using options that start with –
W
, you can control which types of messages should
be displayed. It is a good idea to always use –
Wall
option in your Makefiles. The reason is that
warnings often signify problems in code that you will want to see. Please see
gcc
man pages to
get a feel of options controlling warning messages.
3.7Include files
During the compilation process, the compiler should know where include files will be located.
This can be done in different ways. The compiler looks into some default locations when search-
ing for include files and you have already seen in this chapter how to display that information.
You can also use the –
I
command line switch with the
gcc
command to set additional paths to
locate include files. The third method is the use of environment variables. Please see the environ-
ment variables section earlier in this chapter for more information.
3.8Creating Libraries
Libraries are files containing commonly used functions needed for all programs. For example,
printf()
is a function used in most of the C programs. When the program is linked, the linker
must know where the code for the
printf()
function is located. Knowledge of location of
library files is a must at this stage. The location can be passed to the linker using command line
options or environment variables. In large software projects, this is done inside Makefiles. The
environment variable that shows the location of library files is
LD_LIBRARY_PATH
. Please see
the list of command line options in this chapter or use manual pages to find out which options
are appropriate.
Next Page >>
<< Previous Page
Back to the Table of Contents