Implementation

From WikiPET

Revision as of 10:09, 3 December 2008 by Oikonenv (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

This article is about software implementation environment and tools used by software group of Turku PET Centre.

Contents

Development Environment

GNU C compiler (gcc) is installed in all platforms (unix, linux, Windows XP).

C compiler and platform information

It is recommended that C software (optionally) prints build information, for example:

  printf("\n Build %s %s\n\n",__DATE__,__TIME__);
#if defined(__FILE__) && defined(__TIMESTAMP__)
  printf(" File %s last edited on %s\n", __FILE__, __TIMESTAMP__);
#endif
#if defined(__STDC_VERSION__)
  printf(" Version of C: %ld\n", __STDC_VERSION__);
#endif
#if defined(__STDC_ISO_10646__)
  printf(" Compiler ISO/IEC 10646 specification: %ld\n", __STDC_ISO_10646__);
#endif
#if defined(__GNUC__) && defined(__VERSION__)
  printf(" GNU C version: %s\n", __VERSION__);
#endif

To find out all predefined macros, make an empty file, for example test.h, and then do:

touch test.h
gcc -dM -E test.h

Directories

Source code archives, compiled libraries and binaries for all supported platforms and the working directories are placed in common directory structure below root directory petsoftware. Software directory structure is illustrated in Picture 1. Software developers having access to PET/TUCH network should primarily use and update the resources in svn depository, or petsoftware directory structure.

Image:petsoftware-01.png

Picture 1. Software directory structure. Current sources are kept in folder sources, which is used as working directory for small projects.

Tools and Settings

SUN/Intel Solaris (UNIX, Linux)

GNU C compiler collection gcc 3.2.2, doxygen and various text editors (Emacs, pico, vi, etc.) are installed in the UNIX network at Turku PET Centre.

If you work on PC/Windows, then open MSYS and login to a Solaris workstation. Password on Unix is the same as in Windows.

rlogin jupiter

To compile C libraries and programs, use make. Makefiles for TPC software include special targets which depend on the environment settings. For SUN/Intel Solaris environment variables are set as follows

  1. In terminal window, go to your home directory (cd)
  2. Open file .cshrc.personal with your favourite texteditor
  3. Add the following lines, and save file:
setenv PET_ROOT /pet-storage/petsoftware
setenv INCLUDE '-I. -I./include -I${PET_ROOT}/lib/include'
if ( "`uname -p`" == "sparc" ) then
       setenv OS unix
       setenv AR ar
       setenv LDFLAGS '-L. -L${PET_ROOT}/lib/unix'
       setenv PET_BIN ${PET_ROOT}/bin/unix
       setenv PET_LIB ${PET_ROOT}/lib/unix
else
       setenv OS intel_unix
       setenv AR gar
       setenv LDFLAGS '-L. -L${PET_ROOT}/lib/intel_unix'
       setenv PET_BIN ${PET_ROOT}/bin/intel_unix
       setenv PET_LIB ${PET_ROOT}/lib/intel_unix
       alias ar gar
endif
setenv PET_ARCHIVE ${PET_ROOT}/testarchive
setenv PATH ${PET_BIN}:${PET_ROOT}/bin/common:${PATH}

These environment variables determine behaviour of make:

  1. LDFLAGS: where to look for libraries; first from the current dir then from the lib dir
  2. INCLUDE: where to look for header files; first from the current dir then from the lib dir
  3. PET_BIN: where to install binaries
  4. PET_LIB: where to install libraries
  5. PET_ARCHIVE: where to archive sources, binaries and help files

When you install software with "make -e install", make sure that the copied binary file has execution permission. If not, then give the permissions with command

chmod 777 /pet-storage/petsoftware/bin/unix/yoursoftwarename

If you compile software for other operating systems too, then please do the "make -e distribution" in Solaris first, because we may have an older version of doxygen in Solaris.


PC/Windows

A GNU based C compiler MinGW, UNIX type utility collection MSYS, and doxygen are installed under directory petsoftware/bin/util. To include diagrams and graphs in doxygen documents install also dot tool. Path to utility programs must be set in PATH variable in Windows workstations. Do the following installation steps one time for each computer where programs need to be compiled, or MinGW/MSYS are needed for other purposes.

Notice! If there is another compiler configured on the workstation, such as DJGPP, one should remove all environment variables related to that, prior configuring MinGW. This is done to avoid collisions between compilers.

Finnish Windows XP:

If network drive is automatically mapped (look for \\pet-storage\petsoftware, should be found in all desktops at TPC), skip first three steps.

If network drive is automatically mapped and environment variables are automatically set, skip the following steps, your system is ready to run.

Network drive is mapped with the following steps:

  1. Click right mouse button over icon "Verkkoympäristö"
  2. Select "Yhdistä verkkoasemaan"
  3. Enter drive letter for petsoftware directory structure, e.g. P:, and network path \\pet-storage\petsoftware

If network drive is mapped, path variable can be set with the following steps:

  1. Open "Käynnistä" menu
  2. Select "Asetukset", "Ohjauspaneeli", and "Järjestelmä"
  3. Select "Lisäasetukset" and "Ympäristömuuttujat"
  4. On the upper list, create a new environment variable ("Uusi"): PET_ROOT P: (where "P:" is the network drive letter specified previously)
  5. From the upper list, select PATH and click "Muokkaa", if PATH variable does not exist create new ("Uusi")
  6. Add strings in the end of PATH variable:
;%PET_ROOT%\bin\windows;%PET_ROOT%\bin\common;%PET_ROOT%\bin\Perl;%PET_ROOT%\bin\util\Perl\bin and
;%PET_ROOT%\bin\util\MinGW\bin;%PET_ROOT%\bin\util\MSYS\bin;%PET_ROOT%\bin\util\doxygen\bin
  1. For even more tools one must add the following strings in the end of PATH variable:
;%PET_ROOT%\bin\util\DCMTK;%PET_ROOT%\bin\util\GNUPLot\binaries;%PET_ROOT%\bin\util\Python24;%PET_ROOT%\bin\util\Vim

If network drive is mapped and PATH variable is set, the following variables must be created:

     INCLUDE -I. -I./include -I%PET_ROOT%/lib/include
     LDFLAGS -L. -L%PET_ROOT%/lib/windows
     PET_BIN %PET_ROOT%/bin/windows
     PET_LIB %PET_ROOT%/lib/windows
     PET_ARCHIVE %PET_ROOT%/www/software

See section SUN/Intel Solaris for explanation of the above environment variables.

Ubuntu Linux

This section gives some hints how to setup a PC with Ubuntu 8.04 outside of TPC network for compiling and using TPC software.

Set the environment for compiling and executing programs

By default, Ubuntu is not installed with all the tools that are required to compile C libraries and programs. You must first install the package build-essential either using Synaptic package tool or with terminal command sudo apt-get install build-essential.

Install also Doxygen and Graphviz (dot) using Synaptic package tool.

Go to your home directory (usually /home/username) and open file .bashrc with text editor; this file is hidden by default, therefore you must 'view hidden files' with your file browser. To the end of this file add the following lines (changing the environment variable values as necessary):

export PET_ROOT=/usr/local
export INCLUDE="-I. -I./include -I$PET_ROOT/include/tpc"
export OS=linux_x86
export AR=ar
export PET_LIB=$PET_ROOT/lib/tpc
export LDFLAGS="-L. -L$PET_LIB"
export PET_BIN=$PET_ROOT/bin
export PET_ARCHIVE="$PET_ROOT/src/archive"
export PET_WWW_ARCHIVE="$PET_ROOT/src/www"
PATH=$PET_BIN:$PET_ROOT/bin/common:$PATH

Naturally, you must also create the mentioned directories:

/usr/local/include/tpc
/usr/local/lib/tpc
/usr/local/src
/usr/local/src/archive
/usr/local/src/archive/doc
/usr/local/src/archive/bin
/usr/local/src/archive/src
/usr/local/src/archive/lib
/usr/local/src/archive/libsrc
/usr/local/src/archive/libdoc
/usr/local/src/www
/usr/local/bin/common

and make sure that all users of the computer have access to these directories.

If your computer is connected to TPC network, then you should use the paths that were given for Unix.

Install utility programs for installing and distributing software

These programs are needed to install software using Makefile target install:

  • progvers
  • adddate
  • wrapper.sh and/or wrapper_nowarn.sh (if you like to run latest version of software without entering the version number).

Additionally, these programs would be needed to distributing the software using Makefile target -distribution (but this is probably not useful outside TPC network anyway):

  • pdoc2htm
  • help2xml.pl
  • make_doxyapi.sh
  • make_libbinarchive.sh
  • make_libsrcarchive.sh
  • make_exearchive.sh
  • make_srcarchive.sh
  • make_xmlhelp.sh

Inside TPC all these programs are already installed. Otherwise, you may find the executables for your Linux version in our web pages; then you can just download and unzip the binaries into your path for binaries, for example /usr/local/bin.

If you cannot find suitable binaries or want to compile those yourself, then you need to compile the C libraries first, install libraries manually, then compile utility programs and install those manually to the bin path.

Install C libraries

Compile and install C libraries in the following order:

  1. libtpcmisc
  2. libtpccurveio
  3. libtpcmodel
  4. libtpcimgio
  5. libtpcimgp
  6. libtpcmodext
  7. libtpcsvg
  8. libtpcroi (only needed by few programs)

Go to the directory where you installed the library source files. Copy the library include files to the include path, for example:

cp include/*.h /usr/local/include/tpc/

Enter the following commands for compilation and installing of the library, one library at a time:

make -e compile
make -e install

Check that compilation proceeds without errors. If the utility programs are not available, make -e install will not work, but you have to copy the compiled library (libtpc*.a) manually to the library path, for example:

cp *.a /usr/local/lib/tpc/

Do these steps for all libraries that you may need.

Personal tools