next up previous contents index
Next: 2.5 Building the Documentation Up: 2 Installing SDCC Previous: 2.3 Search Paths   Contents   Index

Subsections


2.4 Building SDCC


2.4.1 Building SDCC on Linux

  1. Download the source package either from the SDCC CVS repository or from the nightly snapshots http://sdcc.sourceforge.net/snap.php, it will be named something like sdcc.src.tar.gz.
  2. Bring up a command line terminal, such as xterm.
  3. Unpack the file using a command like: "tar -xzf sdcc.src.tar.gz", this will create a sub-directory called sdcc with all of the sources.
  4. Change directory into the main SDCC directory, for example type: "cd sdcc".
  5. Type "./configure". This configures the package for compilation on your system.
  6. Type "make". All of the source packages will compile, this can take a while.
  7. Type "make install" as root. This copies the binary executables, the include files, the libraries and the documentation to the install directories.

2.4.2 Building SDCC on OSX 2.x

Follow the instruction for Linux.

On OSX 2.x it was reported, that the default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC. Fortunately there's also gcc 2.9.x installed, which works fine. This compiler can be selected by running 'configure' with:

./configure CC=gcc2 CXX=g++2

2.4.3 Cross compiling SDCC on Linux for Windows

With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32. See section 'Configure Options'.

2.4.4 Building SDCC on Windows

With the exception of Cygwin the SDCC binaries uCsim and sdcdb can't be built on Windows. They use Unix-sockets, which are not available on Win32.

2.4.5 Building SDCC using Cygwin and Mingw32

For building and installing a Cygwin executable follow the instructions for Linux.

On Cygwin a ''native'' Win32-binary can be built, which will not need the Cygwin-DLL. For the necessary 'configure' options see section 'configure options' or the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.

In order to install Cygwin on Windows download setup.exe from www.cygwin.com http://www.cygwin.com/. Run it, set the ''default text file type'' to ''unix'' and download/install at least the following packages. Some packages are selected by default, others will be automatically selected because of dependencies with the manually selected packages. Never deselect these packages!

If you want to develop something you'll need:

rxvt is a nice console with history. Replace in your cygwin.bat the line

bash --login -i 
with (one line):

rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red

     -bg black -fg white -geometry 100x65 -e bash --login

Text selected with the mouse is automatically copied to the clipboard, pasting works with shift-insert.

The other good tip is to make sure you have no //c/-style paths anywhere, use /cygdrive/c/ instead. Using // invokes a network lookup which is very slow. If you think ''cygdrive'' is too long, you can change it with e.g.

mount -s -u -c /mnt
SDCC sources use the unix line ending LF. Life is much easier, if you store the source tree on a drive which is mounted in binary mode. And use an editor which can handle LF-only line endings. Make sure not to commit files with windows line endings. The tabulator spacing used in the project is 8.

2.4.6 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)

Download the source package either from the SDCC CVS repository or from the nightly snapshots http://sdcc.sourceforge.net/snap.php, it will be named something like sdcc.src.tgz. SDCC is distributed with all the projects, workspaces, and files you need to build it using Visual C++ 6.0/NET (except for sdcdb.exe which currently doesn't build under MSVC). The workspace name is 'sdcc.dsw'. Please note that as it is now, all the executables are created in a folder called sdcc\bin_vc. Once built you need to copy the executables from sdcc\bin_vc to sdcc\bin before running SDCC.

In order to build SDCC with MSVC you need win32 executables of bison.exe, flex.exe, and gawk.exe. One good place to get them is here http://unxutils.sourceforge.net

Download the file UnxUtils.zip. Now you have to install the utilities and setup MSVC so it can locate the required programs. Here there are two alternatives (choose one!):

  1. The easy way:

    a) Extract UnxUtils.zip to your C:\ hard disk PRESERVING the original paths, otherwise bison won't work. (If you are using WinZip make certain that 'Use folder names' is selected)

    b) In the Visual C++ IDE click Tools, Options, select the Directory tab, in 'Show directories for:' select 'Executable files', and in the directories window add a new path: 'C:\user\local\wbin', click ok.

    (As a side effect, you get a bunch of Unix utilities that could be useful, such as diff and patch.)
  2. A more compact way:

    This one avoids extracting a bunch of files you may not use, but requires some extra work:

    a) Create a directory were to put the tools needed, or use a directory already present. Say for example 'C:\util'.

    b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe to such directory WITHOUT preserving the original paths. (If you are using WinZip make certain that 'Use folder names' is not selected)

    c) Rename bison.exe to '_bison.exe'.

    d) Create a batch file 'bison.bat' in 'C:\util\' and add these lines:
      set BISON_SIMPLE=C:\util\bison.simple
      set BISON_HAIRY=C:\util\bison.hairy
      _bison %1 %2 %3 %4 %5 %6 %7 %8 %9

    Steps 'c' and 'd' are needed because bison requires by default that the files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory, '/usr/local/share/' I think. So it is necessary to tell bison where those files are located if they are not in such directory. That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.

    e) In the Visual C++ IDE click Tools, Options, select the Directory tab, in 'Show directories for:' select 'Executable files', and in the directories window add a new path: 'c:\util', click ok. Note that you can use any other path instead of 'c:\util', even the path where the Visual C++ tools are, probably: 'C:\Program Files\Microsoft Visual Studio\Common\Tools'. So you don't have to execute step 'e' :)
That is it. Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy the executables from sdcc\bin_vc to sdcc\bin, and you can compile using sdcc.

2.4.7 Building SDCC Using Borland

  1. From the sdcc directory, run the command "make -f Makefile.bcc". This should regenerate all the .exe files in the bin directory except for sdcdb.exe (which currently doesn't build under Borland C++).
  2. If you modify any source files and need to rebuild, be aware that the dependencies may not be correctly calculated. The safest option is to delete all .obj files and run the build again. From a Cygwin BASH prompt, this can easily be done with the command (be sure you are in the sdcc directory):

    find . \( -name '*.obj' -o -name '*.lib' -o -name '*.rul' \) -print -exec rm {} \;

    or on Windows NT/2000/XP from the command prompt with the command:

    del /s *.obj *.lib *.rul from the sdcc directory.


2.4.8 Windows Install Using a Binary Package

  1. Download the binary package from http://sdcc.sourceforge.net/snap.php and unpack it using your favorite unpacking tool (gunzip, WinZip, etc). This should unpack to a group of sub-directories. An example directory structure after unpacking the mingw32 package is: c:\sdcc\bin for the executables, c:\sdcc\include and c:\sdcc\lib for the include and libraries.
  2. Adjust your environment variable PATH to include the location of the bin directory or start sdcc using the full path.


next up previous contents index
Next: 2.5 Building the Documentation Up: 2 Installing SDCC Previous: 2.3 Search Paths   Contents   Index
Bernhard Held 2003-08-29