Compilation Instructions for Icarus Verilog

This page contains advice for compiling and installing Icarus Verilog, taken from the source code distribution. You should read these instructions thoroughly before commencing compilation. If you run into trouble, check the documentation within the source code for more information.

There are generic installation instructions that apply for all systems. The procedure below should work under a Unix-based system.


General Compilation Advice

The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a 'Makefile' in each directory of the package. It may also create one or more '.h' files containing system-dependent definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, a file 'config.cache' that saves the results of its tests to speed up reconfiguring, and a file 'config.log' containing compiler output (useful mainly for debugging 'configure'). If at some point 'config.cache' contains results you don't want to keep, you may remove or edit it.

The file 'configure.in' is used to create 'configure' by a program called 'autoconf'. You only need 'configure.in' if you want to change it or regenerate 'configure' using a newer version of 'autoconf'.

The simplest way to compile this package is:

  1. 'cd' to the directory containing the package's source code and type './configure' to configure the package for your system. If you're using 'csh' on an old version of System V, you might need to type 'sh ./configure' instead to prevent 'csh' from trying to execute 'configure' itself. Running 'configure' takes a while. While running, it prints some messages telling which features it is checking for.
  2. Type 'make' to compile the package.
  3. Optionally, type 'make check' to run any self-tests that come with the package.
  4. Type 'make install' to install the programs and any data files and documentation.
  5. You can remove the program binaries and object files from the source code directory by typing 'make clean'. To also remove the files that 'configure' created (so you can compile the package for a different configuration), type 'make distclean'. There is also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution.

Compilers and Options

Some systems require unusual options for compilation or linking that the 'configure' script does not know about. You can give 'configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this:

   CC=c89; CFLAGS=-O2; LIBS=-lposix; ./configure

Or on systems that have the 'env' program, you can do it like this:

   env CPPFLAGS=-I/usr/local/include LDFLAGS=-s; ./configure

Installation Names

By default, 'make install' will install the package's files in '/usr/local/bin', '/usr/local/man', etc. You can specify an installation prefix other than '/usr/local' by giving 'configure' the option '--prefix=PATH'.

You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give 'configure' the option '--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix.

In addition, if you use an unusual directory layout, you can give options like '--bindir=PATH' to specify different values for particular kinds of files. Run 'configure --help' for a list of the directories you can set and what kinds of files go in them.

If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving 'configure' the option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.

Optional Features

Some packages pay attention to '--enable-FEATURE' options to 'configure', where FEATURE indicates an optional part of the package. They may also pay attention to '--with-PACKAGE' options, where PACKAGE is something like 'gnu-as' or 'x' (for the X Window System). The 'README' should mention any '--enable-' and '--with-' options that the package recognizes.

For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, you can use the 'configure' options '--x-includes=DIR' and '--x-libraries=DIR' to specify their locations.

Specifying the System Type

There may be some features 'configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually 'configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the '--host=TYPE' option. TYPE can either be a short name for the system type, such as 'sun4', or a canonical name with three fields:

   CPU-COMPANY-SYSTEM

See the file 'config.sub' for the possible values of each field. If 'config.sub' isn't included in this package, then this package doesn't need to know the host type.

Operation Controls

'configure' recognizes the following options to control how it operates.

'configure' also accepts some other, not widely useful, options.


Windows Compilation Advice

Icarus Verilog source can be compiled with the Mingw C/C++ compilers to get a Windows binary that does not require the posix compatibility cruft of the Cygwin.dll library. The configure scripts automatically detect that the compilers in use are the Mingw compilers and will configure the Makefiles appropriately.

However, the Mingw tools do not include all the other tools around the compiler, including the shell interpreter for the configure script, bison, flex, gperf, etc. Therefore, you still need Cygwin to compile Icarus Verilog, even if you don't need the Cygwin compilers.

  1. Install Cygwin
    See the web site http://cygwin.com for instructions and the files to do this. Alternatively you can use the Network Installer included on this CD (however there may be more recent versions on the web site).
    In particular, you need the Cygwin base, bison (see notes) flex, make and gperf packages. If you are compiling from CVS, you also need cvs, rcs and automake packages. You will also need tar and gunzip. Installing the "which" package is recommended as well. Beyond the basics, be sure to install these Cygwin packages:
        bison (not 1.875; see notes)
        flex
        ghostscript (makes the documentation)
        perf
        gzip
        make
        strip
        tar (tar and gunzip for unpacking the source)
       unzip (for unpacking zip compressed packages.)
       which
    NOTES
    1:  
    bison-1.875 is broken; it generates invalid C/C++ code. You don't want that version for anything. If you have that version (use "bison -V" to check the version) then use the Cygwin setup program to get a different version. Try downgrading to 1.75 or upgrading to 1.875b.
    2:  There is a mingw32 runtime package included in the Cygwin distribution. You do not need that, as you will be getting everything from the mingw32 distribution itself.
  2. Install Mingw
    These can be found at the project web page http://mingw.org. From the download section you can select various components. Alternatively, just run the installer included on this CD. This gives you all the Mingw packages.
    When I install Mingw32 (using the installer), I typically set a destination directory of d:\mingw-2.0.0 or the like. Remember what you choose because you will be using that path later.
    NOTE
    If you intend to compile VPI modules for Icarus Verilog, you need Mingw32, even if you are using a precompiled version of Icarus Verilog. VPI modules only require Mingw32, and none of the other libraries.
  3. Install Mingw32 Packages
    There is a collection of precompiled libraries and add-on packages that are intended for use with the Mingw32 compiler. Icarus Verilog uses the readline-4.2 package from that collection.
    To open the ZIP file for this package click here: readline-4.2-20010727.zip.
    Since I installed Mingw32 in d:\mingw-2.0.0, I also created a Mingw-packages directory called d:\mingw-packages. The install, then, is as easy as this:
     <cygwin shell>
       $ cd d:/mingw-packages
       $ unzip readline-4.2-20010727.zip
       [ lots of inflating... ]
  4. Install GnuWin32 Packages
    The GnuWin32 project (gnuwin32.sourceforge.net) is a collections of open source programs and libraries ported to Windows. These also work well with the Mingw compiler, and in fact Icarus Verilog uses a few libraries from this collection.
    You will need these gnuwin32 packages (included on this CD) to compile Icarus Verilog:
       bzip2-1.0.2
       
    zlib-1.2.1
    Click the links above to lauch installers and place the packages in a common directory for holding all your GnuWin32 packages. I use D:\gnuwin32.
  5. Unpack Icarus Verilog source
    Most of the remaining steps are best done in a Cygwin window. When you installed Cygwin, a start menu entry was created to allow you to start up the Cygwin window. I'll use the string "$ " to represent a command prompt in this window, because that is the usual bash prompt. Anyhow, unpack the compressed tar file (.tar.gz) of the source with a command like this:
       $ gunzip -d verilog-20040220.tar.gz | tar xvf -
    This will create a directory "verilog-20040220" that contains all the source. Descend into that directory, as that is where we will work from now on.
       $ cd verilog-20040220
  6. Select the Mingw compilers
    In your cygwin window, if you type "which c++" you will get the response path "/usr/bin/c++" which is the cygwin compiler. This is not the one we want to use, however. Tell the shell where the Mingw compilers are by setting the search path like so:
       $ PATH=/cygdrive/d/mingw/bin:$PATH
    This assumes that you installed Mingw in D:\mingw. The actual programs are in the bin directory under the root. After this command, check that you are now getting the right compilers with this "which" command:
       $ which c++
       /cygdrive/d/mingw/bin/c++
    Good!
  7. Configure Icarus Verilog
    Choose a destination path where you will want to install the binaries. I chose on my system the directory "D:\iverilog". This choice is not permanent, so don't get too much angst over it. Just choose a name without white space. Now, configure the source to make the makefiles and configuration details. Run this command:
       $ ./configure --prefix=d:/iverilog
    Substitute your chosen directory for the prefix. This will cause the makefiles to build and the source code to configure. The configure program will detect that this is a Mingw environment and set things up to build properly.
    (For a prefix, use the drive letter notation, the Mingw compiled parts require it, and the Cygwin tools should be able to handle it. You may need to check or upgrade your Cygwin installation if this causes problems for you.)
  8. Compile Icarus Verilog
    This, believe it or not, should be the easy part:
       $ /usr/bin/make
    It could take a while. Now is a good time to go get some coffee or take a tea break. I suggest using the complete path to make, because the Mingw version will not know how to execute the /usr/bin/install program.
  9. Install Icarus Verilog
    If the compile ran OK, then next you install Icarus Verilog in the directory you have chosen. This is a little tricky, however, because the tools like "strip", "ranlib" and etc. that come with Mingw do not understand the Cygwin style paths that are in the makefile. To get around that problem, first remove the Mingw from your path before doing the next step. An easy way to do that is to open a fresh Cygwin window. When you are ready, install like this:
       $ /usr/bin/make install
    This is part of what the configure program did for you. The Makefiles now know to put the files under the D:\iverilog (or whatever directory you chose) directory, and away you go.
  10. Running Icarus Verilog
    Finally, put the D:\iverilog\bin directory in your Windows path, and you should be able to run the iverilog and vvp commands to your heart's content.

Currently, the iverilog.exe uses the path to itself to locate the libraries and modules associated with itself. In other words, if you execute the D:\iverilog\bin\iverilog.exe program, it will locate its subparts in the D:\iverilog directory and subdirectories below that. This means you can move the Icarus Verilog installation by simply moving the root directory and all its contents.


Mac OS X Compilation Advice

The following procedure will build and install Icarus Verilog on Mac OS X. It is assumed that you already have experience with Unix and Terminal.app and a basic knowledge of how to download, compile and install software from source form.

  1. Obtain and install a libdl compatibility library.
    If you don't already have /usr/local/lib/libdl.{a,dylib} and /usr/local/include/dlfcn.h, you can obtain the source for a compatibility layer from
       http://prdownloads.sourceforge.net/fink
    or use the file included on this CD:
       dlcompat-20030629.tar.gz
    Unpack this tar file and read the README and Makefile. Install the library according to the instructions. Installation in /usr/local is strongly recommended since otherwise autoconf very likely won't be able to find it.
  2. Make sure you have a copy of the 'gperf' tool. This does not come with the Mac OS X 10.1 developer tools, so you probably don't. You can check with:
       % which gperf
    If not found, grab a gperf source package and install it. See GPERF for MacOSX below.
  3. Configure, build and install the Icarus Verilog sources as normal.
    The only change you need to make here is to use a configure command like:
       % CC="cc -no-cpp-precomp" ./configure
    This assumes you are using 'sh', 'zsh', or 'bash'. If you are using 'csh' or 'tcsh', then you'll want something like:
       % setenv CC "cc -no-cpp-precomp"
       % ./configure
    You can, of course, add other configure options.
  4. NOTE: 'make check' will not work until after 'make install' has been run since dynamically loaded code is searched for in the install location rather than the build location. The dlopen emulation library doesn't support a search path option.
    If you are worried about overwriting a working installation with a new, potentially broken one, you can always configure using --prefix="/some/path", and install there to make sure everything is working and then re-configure with the real path you want to install at, make clean, and make install.
  5. Done!

GPERF for MacOSX

Unpack gperf source code for version 2.7.2 (included on this CD):
   gperf-2.7.2.tar.gz

Apply a patch to the gperf-2.7.2 source (also on this CD):
   gperf-2.7.2-macosx-patch.gz
using the "patch" program (see the patch documentation for help on how to do this).

Now compile and install according to the instructions given in the gperf source code.