Compiling Software on Solaris

Don't buy Sun's CC compiler unless you have to. For most purposes, GNU CC works just fine and all kinds of great GNU software are written for this compiler.

This is quick and dirty explanation of how to get started compiling software on Solaris platforms with GNU software. I'll get around to filling in the details later. Do searches on the Internet for anything I haven't explained here.

As of May 15, 2004 the URL's in this document were correct. GNU reserves the right to change all file paths (dratted link-rot!).

  1. GET THE SUN MD5 PACKAGE & INSTALL
    If sendmail can get trojanized, anything else can... Use MD5!
    1. Download Solaris Binaries for MD5
    2. Decompress and untar the archive
      zcat md5.tar.Z | tar xvf -
    3. Change the permissions & ownership on the files
      chmod 700 /opt/md5/*
      chown root:root /opt/md5/*
    4. Verify ownership and permissions
      ls -l
    5. Verify the fingerprint of the archive against the MD5 has listed at the site.
  2. VERIFY THE AUTHENTICITY OF WHAT YOU DOWNLOAD
    If you download it, verify the MD5 hash.

    /opt/md5/md5-sparc /path/to/file
  3. GET GCC
    If your version of Solaris has CC (ie. you did the full developer installation of Solaris), you CAN compile it yourself, otherwise, get the binary package from GNU.
    • Browse to <http://www.gnu.org> - bookmark this site.
    • Browse to <http://sunsolve.sun.com> - bookmark this site.
    • Browse to <http://www.sunfreeware.com> - bookmark this site.
    • From SunFreeware, select the appropriate "FTP/Mirror Sites" (sunfreeware is very, very busy)
    • Select your Platform/OS version. If you don't know your architecture/OS, 'cat /etc/motd'. It's usually there.
    • Download the latest stable gcc package. Versions are usually listed using major.minor.revision version numbering. Looking for the highest major and minor numbers and second highest revision number is your best bet as that is usually the stable code. If you're using Netscape, be sure to 'save target'. (Netscape under Solaris 8 and later auto-decompresses .gz files and displays them in the browser.)
  4. INSTALLING THE GCC PACKAGE
    • If the file is still named .gz (ie Netscape didn't decompress it) decompress it yourself.
      gunzip package.gz
    • Install the gcc compiler package using
      pkgadd -d /file/path/to/package
  5. GET THE SOFTWARE SOURCES YOU NEED
    Source bundles are often called distributions. Once GCC is installed, find and download whatever source distribution you need. Typically, these are available in tape archive files that have been compressed with gzip. The names of these files are of the format:

    archive-name.M.m.v.tar.gz
  6. Once you have your source-code.tar.gz file downloaded, decompress it:
    gunzip archive-name.M.m.v.tar.gz
  7. This should produce a file named archive-name.M.m.v.tar in the same directory you are currently in ( use the pwd command if you don't know where you are).
  8. Unpack the archive file using the tape archive command (never mind about it being called a 'tape').
    tar xvf archive-name.M.m.v.tar
  9. As the archive unpacks, it will show all the files on the screen. Once the archive is unpacked, you should end up with a new directory that looks something like the archive, but no tar.
    archive-name.M.m.v
  10. Use the cd comand to switch to the directory where the archive was unpacked into
  11. READ THE DOCUMENTATION - DO NOT SKIP THIS STEP!
    1. WHAT TO READ- Type more followed by the filename. Remember that Unix filenames are case-sensitive.
      • more README
        This is usually information about the package itself, what it's for and what it does and who wrote it.
      • more INSTALL
        This file has been included in nearly every distribution I have compiled. It has always contained a step by step set of instructions for building and installing the software. This will also contain information about different ways to compile the software, the two most important being the choice of creating a static binary or dynamic binary. Other options include features to add compatibility with other packages. The OpenSSH distribution has options for compatibility with PAM and TCPwrappers for instance).
      • more BUGS - known software bugs and other errata
      • more PROBLEMS - top ten problems the developers have had reported to them.
      • Read anything else that looks even remotely interesting.
    2. RESOLVE DEPENDANCIES - Nearly all packages require certain libraries from the system or require other software libraries you might have to download. The website where the software is offered for download often has this information as does the README or INSTALL file in the software package.
    3. SET YOUR PATH & ENVIRONMENT VARIABLES - Make sure the appropriate library directories are in your path or the installation instructions are worthless.
  12. Reading the INSTALL file, you will discover that it will recommend running one or more of the following commands in the order they appear below:
    • ./configure
      This guesses settings for proper software compiling.
    • make
      Make looks in the current directory for a file literally called "Makefile". This directive file contains targets which instruct make on how to build the software.
    • make test
      This tests the work make has done.
    • make install
      This copies (installs) the binaries and/or associated libraries into appropriate folders on the Sun system.
    • make clean
      Not always available, this cleans up the source and removes the binary files in the directory where it was built. Typically, you can remove the directory where the software was unpacked from. In fact, many administrators actually download the archive to /var/tmp and extract it there because the contents of /var/tmp is deleted when the system is rebooted.
  13. Problems with make are almost always a dependancy or environment variable (usually $PATH) problem. Re-run the make command with a -d or -dd flag for more details about the error.
  14. Finally, some software requires additional configuration. The INSTALL file will usually contain information about which configuration files need to be altered to make the software work as you need it. The Apache HTTPd server is just one such application and uses an httpd.conf file for just this purpose.

 

 


Bookmark this page and SHARE:  

Search

Support InetDaemon.Com

Get Tutorials in your INBOX!

Free Training

Free Training