- Introduction to GNU C and C++ Compilers
- Installing GNU Compiler
- Compiling a Program
- Linking a program
- Assembling a Program
- Handling Warning and Error messages
- Include files
- Creating Libraries
- Standard Libraries
- Compiling Pascal Programs
- Compiling Fortran Programs
- Other Compilers
- References and Resources
3.5 Assembling a Program
GNU assembler is part of GNU binary utilities package. To get the latest binutils packages, you can download it from ftp://ftp.gnu.org/gnu/binutils/. After downloading you have to use the tar command to extract source code files. The latest version at the time of writing this chapter is 2.12 and the tar command will create a directory binutils-2.12 automatically. I have extracted it in /opt directory, so the source code directory is /opt/binutils-2.12. I created another directory /opt/binutils-build to build the package. Running the configure script is the first step towards building binary utilities package. The following sequence of commands does all of these steps.
[root@conformix /opt]# cd /opt [root@conformix /opt]# tar zxvf binutils-2.12.tar.gz [root@conformix /opt]# mkdir binutils-build [root@conformix /opt]# cd binutils-build/ [root@conformix binutils-build]# ../binutils-2.12/configure --prefix=/opt/gcc-3.0.4 --enable-shared [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 destination for installation, the binary utilities will be installed in /opt/gcc-3.0.4/bin directory. 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.