BUILD_NOTES_MacOSX 29.8 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
                      Building VisIt on MacOS X 10.3
                     ================================

   This document describes how to build VisIt on MacOS X. Building on MacOS X,
while similar enough to other versions of UNIX but there are enough differences
to warrant these special instructions. Most of the differences arise from how
MacOS X provides support for advanced linking options such as prebinding, which
helps applications launch faster. We build VisIt and all of its support
libraries with prebinding enabled because it substantially improves VisIt's
startup time on MacOS X. Unfortunately, prebinding introduces a lot of
complexity with respect to building VisIt's support libraries because they each
have varying degrees of support for MacOS X. In fact, only Qt has built-in
support for prebinding. To enable prebinding for all of the other support
libraries, follow the instructions in this document for building each library
before finally building VisIt.

VisIt relies on several external libraries which must be built and installed
prior to building VisIt.  This document provides detailed step by step
instructions for building VisIt and each of the dependent libraries.  The
instructions have been designed so that you can cut and paste most of the
commands needed to build the libraries and VisIt from this file into your
shell prompt.


hrchilds's avatar
hrchilds committed
25
    Library  Version  Description            For More Information
hrchilds's avatar
hrchilds committed
26 27 28 29
    =======  =======  ===========            ====================
    Mesa     5.0.2    3-D Graphics Library   http://www.mesa3d.org/
    Python   2.3.3    Scripting Language     http://www.python.org
    Qt       3.3.1    GUI Toolkit            http://www.trolltech.com
hrchilds's avatar
hrchilds committed
30 31
    Silo     4.4.3    File I/O library       http://www.llnl.gov/bdiv/meshtv
                                             ftp://ftp.llnl.gov/pub/visit/3rd_party/silo050506.sh
hrchilds's avatar
hrchilds committed
32
    VTK      20031028 Visualization Toolkit  http://www.kitware.com
hrchilds's avatar
hrchilds committed
33 34
    HDF5     1.6.0    I/O library            http://hdf.ncsa.uiuc.edu/HDF5/
    
hrchilds's avatar
hrchilds committed
35
    Optional Version  Description            For More Information
hrchilds's avatar
hrchilds committed
36 37
    ======== =======  ===========            ====================
    Mili     1.06     I/O library            (none)
hrchilds's avatar
hrchilds committed
38
    HDF4     2.0      I/O library            http://hdf.ncsa.uiuc.edu/release4/obtain.html
hrchilds's avatar
hrchilds committed
39 40 41 42 43 44 45

The public version of VisIt has been built with the above listed versions
of the libraries, so it is known to work properly with those versions.  For
all the packages except VTK and Qt, you can probably use newer versions of the
packages and VisIt should work properly.  For Mesa, you must build a mangled
version of Mesa.  The distribution provided has already been set up to build
a mangled version so no additional work is required if you use it.  For VTK,
hrchilds's avatar
hrchilds committed
46 47 48 49 50 51 52
you must use the October 28, 2003 distribution provided. The version of Qt
used to build VisIt on MacOS X must be greater than or equal to 3.0.

Most of the third party libraries necessary to build VisIt are available for
download from ftp://ftp.llnl.gov/pub/visit/3rd_party.  It is suggested that
you start there and then go to the "For More Information" web sites for
any remaining libraries.
hrchilds's avatar
hrchilds committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

It is essential that you build all the dependent packages and VisIt using
the same c++ compiler or you will encounter linking problems because different
compilers or different versions of the same compiler may use different name
mangling schemes. For MacOS X, we recommend using g++ 3.3.


==============================================================================
Crucial linker flags for prebinding a library or application
==============================================================================

-prebind             The -prebind flag should be used for applications and
                     libraries that you want to be prebound. Put the -prebind
		     flag in your LDFLAGS or wherever you provide arguments
		     to the linker. Prebinding allows your application to
		     start faster because all symbols are already resolved
		     and resolution is not required when the application is
		     launched. Furthermore, since prebinding requires that
		     all libraries used in the application have distinct, non-
		     overlapping memory ranges, the linker can compute
		     appropriate relocation offsets at link time.

-twolevel_namespace  A two level namespace is what's commonly used on most
                     platforms but MacOS X initially came with just a flat
		     namespace, which prevented duplicate symbols in the
		     same application. A two level namespace allows duplicates
		     and is more forgiving, though possibly error prone if
		     there are multiple symbols with the same name. Two-level
		     symbol resolution also takes a little longer.

-install_name        The -install_name flag inserts the name of the library
                     into the actual dylib file. Normally if you do not
		     provide this flag, the path where you built the library is
		     inserted into the dylib file and applications that link
		     with the dylib look for it in the path stored in the dylib,
		     which easily leads to the library not being found. In order
		     to make sure that the system can find the dylib file used
		     by your application, make sure you build dylib files so
		     their installed name is relative to the executable.
		   
		     For VisIt, which has a bin directory and a separate lib
		     directory for libraries, we set the installation name like
		     this:
		     
		     -install_name,@executable_path/../lib/libfoo.dylib.
		     
		     The above example makes sure that applications in bin that
		     linked with libfoo.dylib look for it in ../lib instead of
		     a hardcoded path.
		 
-seg1addr            The -seg1addr flag tells the linker where the first segment
                     of your library should start in memory. Prebinding is not
		     enabled unless all of your libraries and your application
		     that uses them have memory ranges that do not overlap at
		     all. Computing the segment address for a complex project
		     like VisIt can be tricky and Makefile tricks are required
		     if you want the offset to be computed on the fly,
		     determined by the sizes of your libraries as they are built.
		     To specify the starting segment address, do this:
		     
		     -Wl,-seg1addr,0x20000000

                     Look at VisIt's linkedit.py and configure.in scripts to
		     see how to compute the segment offset on the fly using
		     autoconf and Makefiles.

==============================================================================
Segment offset
==============================================================================

The initial segment offset for VisIt's support libraries begins at 0x...
, right after Qt's ending address. The memory addresses used in this document
reflect the sizes of the libraries as they were built at the time of VisIt 1.3.
We chose segment offsets that pack the libraries into a fairly contiguous
block of memory so no libraries interfere with each other.

==============================================================================
otool
==============================================================================

MacOS X has a utility called otool that allows you to examine the contents of
a dynamic library or an executable. Otool is very handy for determining whether
a dynamic library was actually built with prebinding. Here are the most useful
options for otool:

# Print the Mach header. If the library is prebound, it will have the word
# PREBOUND in the output. If the output does not contain PREBOUND then you
# need to make changes to your library and relink until it is prebound because
# unless an application and *all* of its dependent libraries are prebound,
# it cannot use prebinding.
otool -hv libfoo.dylib

# Print all of the library dependencies
otool -hvL libfoo.dylib

hrchilds's avatar
hrchilds committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
==============================================================================
Support libraries
==============================================================================

Most of the instructions in this document are for building the various support
libraries that VisIt depends on as prebound dynamic libraries. Few of the
libraries that VisIt uses actually have support in their make system for
producing prebound dynamic libraries so it is imperative that you follow the
directions or VisIt will not be prebound. Remember that you can always use the
otool command to check whether a library or executable is prebound.

Before building VisIt or any of its support libraries, you need to create a
"visit" directory in which the support libraries will be installed. We also create
file that contains the path so we can use that in some of the instructions
later on.

mkdir visit
echo `pwd`/visit > visitpath
hrchilds's avatar
hrchilds committed
166
set VISITPATH="`pwd`/visit"
hrchilds's avatar
hrchilds committed
167

hrchilds's avatar
hrchilds committed
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
==============================================================================
Building Qt as a set of prebound dynamic libraries
==============================================================================

Qt actually builds as a prebound dynamic library but we need to make sure
that it sets an install_name that is relative to our VisIt executables.

# Build Qt 3.3.1 for MacOS X
gunzip qt-mac-free-3.3.1.tar.gz
tar xvf qt-mac-free-3.3.1.tar
cd qt-mac-free-3.3.1
setenv QTDIR `pwd`
./configure
make

# Qt built but we need to change it a little.
cd src
vi Makefile
Add -install_name @executable_path/../lib/libqt.dylib to LFLAGS and save
rm ../lib/libqt*
make

# Install Qt
hrchilds's avatar
hrchilds committed
191 192 193 194 195 196 197 198
mkdir $VISITPATH/qt
mkdir $VISITPATH/qt/bin
mkdir $VISITPATH/qt/include
mkdir $VISITPATH/qt/include/private
mkdir $VISITPATH/qt/lib
cp bin/{designer,findtr,moc,qt20fix,qtrename140} $VISITPATH/qt/bin
cd include; cp *.h $VISITPATH/qt/include
cp private/*.h $VISITPATH/qt/include/private
hrchilds's avatar
hrchilds committed
199
cd ../lib
hrchilds's avatar
hrchilds committed
200
cp libqt-mt.3.3.1.dylib $VISITPATH/qt/lib/libqt.dylib
hrchilds's avatar
hrchilds committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
cd ../..

==============================================================================
Building Mesa as a set of prebound dynamic libraries
==============================================================================		    

Mesa is a 3-D graphics library with an API which is very similar to that of
OpenGL.  It is used for performing off-screen rendering.

#
# Build Mesa
#
tar zxvf Mesa-5.0.2.tar.gz
cd Mesa-5.0.2

#
# Special instructions for building Mesa on MacOS X
#
# The darwin target for building Mesa assumes that you want to build Mesa
# with support for X11. This is not what we want to do for the version of
# Mesa that we'll use for VisIt since we only want offscreen rendering.
#
# 1. Open Make-config and remove all X include files and libraries from
#    the darwin target. Also add -DUSE_MGL_NAMESPACE to the CFLAGS and
#    CCFLAGS so a mangled version of Mesa will be built. Next, change
#    GL_LIB so it will build a library called libMesaGL.dylib instead of
#    libGL.dylib. Finally, edit GLU_LIB_DEPS so it uses -lMesaGL instead
#    of -lGL.
# 2. Open bin/mklib.darwin and look for an if/then/else block that sets
#    different flags for each of the libraries being linked. Change
#    libGL.dylib to libMesaGL.dylib since in the previous instructions,
#    we renamed the Mesa library.
#
#    For libMesaGL.dylib, add:
#       EXTRA_FLAGS="${EXTRA_FLAGS} -prebind -Wl,-seg1addr,0x2098a000"
#
#    For libOSMesa.dylib, add:
#       EXTRA_FLAGS="${EXTRA_FLAGS} -prebind -Wl,-seg1addr,0x20bd7000"
#
#    The additions above will cause the two modified libraries to be built
#    as prebound dynamic libraries, which will help reduce VisIt's start
#    time.
hrchilds's avatar
hrchilds committed
243
# 3. Open src/mesa/Makefile.X11 and remove all of the source code files from
hrchilds's avatar
hrchilds committed
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
#    the DRIVER_SOURCES variable so it is defined as:
#    DRIVER_SOURCES = 
#
# ** Note - After you start building Mesa with these changes, it will fail
#           after successfully building libMesaGL.dylib and libOSMesa.dylib.
#           This is okay since those are the only libraries we want.
#           Continue on to building VTK.
#

#
# Build Mesa by typing in the Mesa-5.0.2 directory.
#
make darwin

#
# Install Mesa
#
hrchilds's avatar
hrchilds committed
261 262 263 264 265
mkdir $VISITPATH/mesa
mkdir $VISITPATH/mesa/{include,lib}
mkdir $VISITPATH/mesa/include/GL
cp include/GL/*.h $VISITPATH/mesa/include/GL
cp lib/*.dylib $VISITPATH/mesa/lib
hrchilds's avatar
hrchilds committed
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
cd ..

==============================================================================
Building CMake in order to build VTK
==============================================================================

CMake is a cross-platform make system used to build VTK. Before building VTK,
we must build CMake

gunzip cmake-1.8.1.tar.gz
tar xf cmake-1.8.1.tar
cd cmake-1.8.1
env CXXFLAGS="" ./bootstrap
make
cd ..

==============================================================================
Building VTK as a set of prebound dynamic libraries
==============================================================================

VTK is an object oriented library for visualizing 3D data.  VisIt uses it
for all its visualization functionality. Follow the directions listed below
to build VTK.  If you have any problems building or installing VTK, read the
VTK/README.html file included in the VTK distribution for more information.

gunzip vtk_cvs_2003_10_28.tar.gz
tar xf vtk_cvs_2003_10_28.tar
cd VTK
../cmake-1.8.1/bin/cmake .
#
# Edit CMakeCache.txt.  Turn BUILD_SHARED_LIBS, VTK_USE_HYBRID, and
# VTK_USE_MANGLED_MESA on, Turn BUILD_TESTING off.
#
# Look for the following CMake keys and set these values:
#
# CMAKE_BUILD_TYPE:STRING = Release
hrchilds's avatar
hrchilds committed
302
# CMAKE_CXX_FLAGS_RELEASE:STRING = '-O2'
hrchilds's avatar
hrchilds committed
303 304 305 306
# CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING='-prebind'
# CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING='-prebind'
# CMAKE_SHARED_LINKER_FLAGS_RELASE:STRING='-prebind'
# CMAKE_VERBOSE_MAKEFILE:BOOL=TRUE
hrchilds's avatar
hrchilds committed
307
# VTK_USE_MANGLED_MESA:BOOL=ON
hrchilds's avatar
hrchilds committed
308
#
hrchilds's avatar
hrchilds committed
309 310
# Look for -flat_namespace and replace it with -twolevel_namespace, delete
# the -U flag and its argument.
hrchilds's avatar
hrchilds committed
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
#
../cmake-1.8.1/bin/cmake .
make

VTK does not provide targets for building prebound shared libraries. Rather than
change VTK's build process permanently, which I did not see how to do since I am
a CMake novice, I chose to edit the Makefiles generated by CMake after VTK was
built. I needed the size for all of the VTK libraries anyway in order to
calculate good offsets for them. The offset for the first VTK library is after
the last Mesa library so eventually we will have built all of VisIt's support
libraries so that they could be layed out in memory at their starting addresses
and never touch.

Library                 Segment Offset (hex)
=============================================
libvtkzlib.dylib        20be6000
libvtkjpeg.dylib        20bf5000
libvtkpng.dylib         20c18000
libvtktiff.dylib        20c3b000
libvtkexpat.dylib       20c86000
libvtkfreetype.dylib    20ca8000
libvtkftgl.dylib        20cfc000
libvtkDICOMParser.dylib 20d17000
libvtkCommon.dylib      20dec000
libvtkFiltering.dylib   21111000
libvtkGraphics.dylib    2125b000
libvtkIO.dylib          2186a000
libvtkImaging.dylib     21b96000
libvtkRendering.dylib   21f6f000
libvtkHybrid.dylib      21601000 (offset out of order but that's okay)

Since we added -prebind to the flags that are used when trying to link a shared
library, we can open each Makefile for the projects listed above and add the
above offsets after the -prebind flag. Before adding offsets though, you should
remove all of the shared libraries in the VTK/bin directory so make will cause
a relink of the libraries as we build them one by one.

Example:
   1. cd Utilities/zlib
   2. vi Makefile
   3. Search for -prebind
   4. After -prebind, add:
      -Wl,-seg1addr,0x20be6000,-install_name,@executable_path/../lib/libvtkzlib.dylib,-compatibility_version,4.2,-current_version,4.2
      
      Be sure to use the right library name in for the -install_name linker flag since that
      name is put into the library so the runtime linker can find the library relative
      to the executable's path. This helps make applications double-clickable.
      
   5. Save and exit vi
   6. make
   
Note: Be sure that you use a different offset for each library or prebinding will
      fail. The offsets for each VTK library are in the above table. Those offsets
      were computed by first building VTK and calculating the size of each library
      and then calculating an offset that arranges them safely one after another
      in a linear block of memory. There are small gaps between the libraries due
      to the algorithm that was used to lay them out in memory and because of
      segment alignment, which is currently 0x1000.
      
#
# Install VTK in the visit directory under the vtk directory.
#
hrchilds's avatar
hrchilds committed
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
mkdir $VISITPATH/vtk
mkdir $VISITPATH/vtk/{Common,Filtering,Graphics,Hybrid,IO,Imaging,Rendering,MangleMesaInclude,lib}
cp vtkConfigure.h                 $VISITPATH/vtk
cp vtkToolkits.h                  $VISITPATH/vtk
cp vtk*Instantiator.h             $VISITPATH/vtk
cp Utilities/zlib/zlib.h          $VISITPATH/vtk
cp Utilities/zlib/zconf.h         $VISITPATH/vtk
cp Utilities/zlib/zlibDllConfig.h $VISITPATH/vtk
cp Utilities/tiff/*.h             $VISITPATH/vtk
cp Common/*.h                     $VISITPATH/vtk/Common
cp Filtering/*.h                  $VISITPATH/vtk/Filtering
cp Graphics/*.h                   $VISITPATH/vtk/Graphics
cp Hybrid/*.h                     $VISITPATH/vtk/Hybrid
cp IO/*.h                         $VISITPATH/vtk/IO
cp Imaging/*.h                    $VISITPATH/vtk/Imaging
cp Rendering/*.h                  $VISITPATH/vtk/Rendering
cp MangleMesaInclude/*.h          $VISITPATH/vtk/MangleMesaInclude
cp bin/*.dylib                    $VISITPATH/vtk/lib
hrchilds's avatar
hrchilds committed
391 392
cd ..

hrchilds's avatar
hrchilds committed
393 394 395 396 397 398 399 400 401
#
# Install the VTK JPEG library under the visit directory in case the
# computer does not have a JPEG library.
#
mkdir $VISITPATH/jpeg $VISITPATH/jpeg/include $VISITPATH/jpeg/lib
cp Utilities/jpeg/*.h             $VISITPATH/jpeg/include
cp bin/libvtkjpeg.dylib           $VISITPATH/jpeg/lib/libjpeg.dylib


hrchilds's avatar
hrchilds committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
The next offset after libvtkRendering.dylib, which has an offset of 0x21f6f000 and
a library size of 3,260,676 (0x31c104) bytes is:

# Next offset
offset = 0x21f6f000 + int(float(0x31c104) * 1.05)
# Align the offset tp 0x1000 byte boundaries
offset = offset + (0x1000 - offset % 0x1000)
# Next offset
offset = 0x222b3000

===============================================================================
Building Python as a prebound dynamic library
===============================================================================

Python is a powerful, free scripting language that is used to drive VisIt's
viewer when running VisIt without a GUI. Python is cross platform and runs on
many UNIXes as well as MS Windows and other platforms. VisIt can be configured
to run without Python if scripting features are not desired.  Follow the
directions listed below to build Python.  If you have any problems building
or installing Python, read the README file in the Python distribution for more
information.

I could not get Python 2.1.2 to build all of the way on Panther (MacOS X 10.3) so I
downloaded the newer Python 2.3.3.

tar zxvf Python-2.3.3.tgz
cd Python-2.3.3
env OPT="-O3 -Wall -Wstrict-prototypes -fno-common -fPIC" ./configure --prefix=`cat ../visitpath`/python
make
hrchilds's avatar
hrchilds committed
431 432

# Install Python
hrchilds's avatar
hrchilds committed
433 434 435 436 437 438 439 440 441
make install

# Now that Python is built, we need to create a shared library version.
mkdir tmplib
cd tmplib
ar -x ../libpython2.3.a
echo "char **environ=0;" > environhack.c
gcc -o environhack.o -c environhack.c
gcc -dynamiclib -prebind -Wl,-seg1addr,0x222b3000,-install_name,@executable_path/../lib/libpython2.3.dylib,-compatibility_version,2.3.3,-current_version,2.3.3 -twolevel_namespace -o libpython2.3.dylib *.o -framework Carbon
hrchilds's avatar
hrchilds committed
442
cp libpython2.3.dylib $VISITPATH/python/lib/python2.3/config/libpython2.3.dylib
hrchilds's avatar
hrchilds committed
443
cd ../..
hrchilds's avatar
hrchilds committed
444 445 446 447 448 449 450 451 452 453 454

The next offset after libpython.dylib, which has an offset of 0x222b3000 and a library
size of 3,311,968 (0x328960) bytes is:

# Next offset
offset = 0x222b3000 + int(float(0x328960) * 1.05)
# Align the offset to 0x1000 byte boundaries
offset = offset + (0x1000 - offset % 0x1000)
# Next offset
offset = 0x22605000

hrchilds's avatar
hrchilds committed
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
===============================================================================
Building HDF5 as a prebound dynamic library
===============================================================================

HDF5 is a data storage library that allows you to efficiently write large
volumes of structured storage to a disk file. VisIt can technically be built
without support for HDF5 so it is an optional, but recommended, package. Though
it is optional, we build it before the Silo library because the Silo library
should be built with support for HDF5 when possible. If you don't want to build
HDF5, you can skip this section but you will have to take care that you do not
attempt to build Silo with support for HDF5.

tar zxvf hdf5-1.6.0.tar.gz
cd hdf5-1.6.0
env CFLAGS="-O2 -fPIC" ./configure
make

# The HDF5 libraries get built, even as dylib shared libraries. That's
# not quite good enough though since we want to set the beginning 
# address of the library and make it be prebound. We'll build our own
# version of the library using the prebuilt sources.
cd src
gcc -dynamiclib -prebind -twolevel_namespace -Wl,-seg1addr,0x22605000,-install_name,@executable_path/../lib/libhdf5.dylib,-compatibility_version,1.6,-current_version,1.6 -o libhdf5.dylib *.lo -lz

# Install HDF5
mkdir $VISITPATH/hdf5
mkdir $VISITPATH/hdf5/include
mkdir $VISITPATH/hdf5/lib
cp libhdf5.dylib $VISITPATH/hdf5/lib
cp *.h $VISITPATH/hdf5/include
cd ../..

The next offset after libhdf5.dylib, which has an offset of 0x22605000 and
a library size of 1,055,884 (0x101c8c) bytes is:

# Next offset
offset = 0x22605000 + int(float(0x101c8c) * 1.05)
# Align the offset to 0x1000 byte boundaries
offset = offset + (0x1000 - offset % 0x1000)
# Next offset
offset = 0x22714000

hrchilds's avatar
hrchilds committed
497 498 499 500 501 502 503 504 505 506
===============================================================================
Building Silo as a prebound dynamic library
===============================================================================

Silo is a self-describing, machine-independent scientific file format.
Silo is one of the file formats supported by VisIt.  Follow the directions
listed below to build Silo.  If you have any problems building or installing
Silo, read the INSTALL_NOTES file in the SILO distribution for more
information.

hrchilds's avatar
hrchilds committed
507 508 509 510 511 512 513
Note that these instructions assume that Silo will be built with HDF5 support.
If you don't want to build Silo with HDF5 support, replace the --with-hdf5=...
with --without-hdf5. The library segment offsets used assume that Silo will be
built with support for HDF5. If you choose to disable HDF5 support, the
offsets will not be affected since the HDF5 version of the Silo library
should be larger.

hrchilds's avatar
hrchilds committed
514
# Build silo source into an archive library
hrchilds's avatar
hrchilds committed
515 516
sh silo050506.sh
cd silo050506
hrchilds's avatar
hrchilds committed
517 518 519 520
# Set the values of some helper variables (tcsh)
set HDF5INCLUDE=$VISITDIR/hdf5/include
set HDF5LIB=$VISITDIR/hdf5/lib
env CFLAGS="-O2 -fno-common -fPIC" ./configure --disable-sdx --without-readline --without-exodus --with-hdf5=$HDF5INCLUDE,$HDF5LIB
hrchilds's avatar
hrchilds committed
521 522 523 524 525 526 527 528
make

# Turn the archive library into a prebound dynamic library

cd lib
mkdir tmplib
cd tmplib
ar -x ../libsilo.a
hrchilds's avatar
hrchilds committed
529
gcc -dynamiclib -prebind -twolevel_namespace -Wl,-seg1addr,0x22714000,-install_name,@executable_path/../lib/libsilo.dylib,-compatibility_version,4.4.3,-current_version,4.4.3 -o ../libsilo.dylib *.o -L$HDF5LIB -lhdf5
hrchilds's avatar
hrchilds committed
530 531 532
cd ..

# Install Silo
hrchilds's avatar
hrchilds committed
533 534 535 536 537 538 539 540
mkdir $VISITDIR/silo
mkdir $VISITDIR/silo/include
mkdir $VISITDIR/silo/lib
cp silo/silo/silo.h   $VISITDIR/silo/include
cp silo/silo/silo.inc $VISITDIR/silo/include
cp silo/sdx/sdx.h     $VISITDIR/silo/include
cp silo/sdx/sdx.inc   $VISITDIR/silo/include
cp lib/libsilo.dylib  $VISITDIR/silo/lib
hrchilds's avatar
hrchilds committed
541 542
cd ..

hrchilds's avatar
hrchilds committed
543 544
The next offset after libsilo.dylib, which has an offset of 0x22714000 and a library
size of 595,036 (0x9145c) bytes is:
hrchilds's avatar
hrchilds committed
545 546

# Next offset
hrchilds's avatar
hrchilds committed
547
offset = 0x22714000 + int(float(0x9145c) * 1.05)
hrchilds's avatar
hrchilds committed
548 549 550
# Align the offset to 0x1000 byte boundaries
offset = offset + (0x1000 - offset % 0x1000)
# Next offset
hrchilds's avatar
hrchilds committed
551
offset = 0x227ad000
hrchilds's avatar
hrchilds committed
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572

===============================================================================
Building Mili as a prebound dynamic library
===============================================================================

Mili is a database file format library for finite element codes. VisIt
has a database reader for this popular LLNL engineering database file
format. Mili file format support is optional and is not required for
VisIt to run.

gunzip mili.tar.gz
tar xvf mili.tar
cd Mili/src

I could not figure out Mili's strange build system, especially since
it does not support MacOS X so I built my own Mili library using a
Makefile that I wrote. Save the following lines to a Makefile in
the Mili's src directory

CC=gcc
CFLAGS = -I. -O2 -fno-common -fPIC
hrchilds's avatar
hrchilds committed
573 574
MILI_LDFLAGS=-Wl,-seg1addr,0x227b0000 -L. -lgahl
GAHL_LDFLAGS=-Wl,-seg1addr,0x227ad000
hrchilds's avatar
hrchilds committed
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
LDFLAGS=-dynamiclib -prebind -twolevel_namespace -Wl,-install_name,@executable_path/../lib/$@
.SUFFIXES : .o .c
MILI_SRC=mili.c direc.c param.c io.c util.c dep.c svar.c srec.c mesh_u.c wrap_c.c io_mem.c eprtf.c sarray.c
MILI_OBJ=${MILI_SRC:.c=.o}
GAHL_SRC=gahl.c
GAHL_OBJ=$(GAHL_SRC:.c=.o)
MILI_LIB=libmili.dylib
GAHL_LIB=libgahl.dylib
all: $(MILI_LIB)
$(MILI_LIB): $(GAHL_LIB) $(MILI_OBJ)
	$(CC) -o $@ $(LDFLAGS) $(MILI_LDFLAGS) $(MILI_OBJ)
$(GAHL_LIB): $(GAHL_OBJ)
	$(CC) -o $@ $(LDFLAGS) $(GAHL_LDFLAGS) $(GAHL_OBJ)
clean: 
	rm -f *.a *.o $(MILI_LIB) $(GAHL_LIB)

Now that you're in Mili's source directory and you have a Makefile, 
type: make

# Install Mili
hrchilds's avatar
hrchilds committed
595 596 597 598
mkdir $VISITPATH/mili
cp *.dylib $VISITPATH/mili
cp mili.h $VISITPATH/mili
cp mili_enum.h $VISITPATH/mili
hrchilds's avatar
hrchilds committed
599 600
cd ../..

hrchilds's avatar
hrchilds committed
601
The next offset after libmili.dylib, which has an offset of 0x227b0000 and
hrchilds's avatar
hrchilds committed
602 603 604
a library size of 109,556 (0x1abf4) bytes is:

# Next offset
hrchilds's avatar
hrchilds committed
605
offset = 0x227b0000 + int(float(0x1abf4) * 1.05)
hrchilds's avatar
hrchilds committed
606 607 608
# Align the offset to 0x1000 byte boundaries
offset = offset + (0x1000 - offset % 0x1000)
# Next offset
hrchilds's avatar
hrchilds committed
609
offset = 0x227cd000
hrchilds's avatar
hrchilds committed
610

hrchilds's avatar
hrchilds committed
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
==============================================================================
Building HDF4 as a prebound dynamic library
==============================================================================

HDF4 is a data storage library that lets you write large volumes of data to 
disk files and it is the predecessor of HDF5. Like most of the other libraries
mentioned so far, HDF4 does not have a make target to produce a prebound, dynamic
library. In fact, its make target for MacOS X produces a static library. Follow
the instructions below for creating prebound dynamic libraries.

# Unpack HDF4
tar zxvf HDF4.2r0.tar.gz
cd HDF4.2r0

vi configure
# Comment out lines 7147-7169 because the script exits with a failure to
# calculate the size of int*. Insert, at line 7178, ac_cv_sizeof_intp=4
# Save the file and exit.
env CFLAGS="-O2 -fno-common" ./configure --with-jpeg=$VISITPATH/jpeg --disable-fortran
make

# Relink libdf and install it.
cd hdf/src
mkdir tmp
cd tmp
ar -x ../libdf.a
gcc -dynamiclib -prebind -twolevel_namespace -o libdf.dylib *.o -L$VISITPATH/jpeg/lib -ljpeg -lz -Wl,-seg1addr,0x227cd000,-install_name,@executable_path/../lib/libdf.dylib,-compatibility_version,2.0,-current_version,2.0
mkdir $VISITPATH/hdf4
mkdir $VISITPATH/hdf4/lib
mkdir $VISITPATH/hdf4/include
mv libdf.dylib $VISITPATH/hdf4/lib

# Relink libmfhdf and install it.
cd ../../../mfhdf/libsrc
mkdir tmp
cd tmp
ar -x ../libmfhdf.a
gcc -dynamiclib -prebind -twolevel_namespace -o libmfhdf.dylib *.o L$VISITPATH/jpeg/lib -L$VISITPATH/hdf4/lib -ljpeg -ldf -Wl,-seg1addr,0x2286000,-install_name,@executable_path/../lib/libmfhdf.dylib,-compatibility_version,2.0,-current_version,2.0
mv libmfhdf.dylib $VISITPATH/hdf4/lib
cd ../../..

# Install the HDF4 header files
cp hdf/src/*.h      $VISITPATH/hdf4/include
cp mfhdf/libsrc/*.h $VISITPATH/hdf4/include
cd ..
hrchilds's avatar
hrchilds committed
656 657 658 659 660 661 662

===============================================================================
Building VisIt with prebinding
===============================================================================

Since we may want to add other libraries to our list of prebound
dynamic libraries, for database reader plugins, etc, we should 
hrchilds's avatar
hrchilds committed
663 664 665 666 667
reserve a memory range after the Python library. Suppose all other
libraries that we want can fit in 10Mb. If that assumption becomes invalid,
we can recalculate the offset for the VisIt libraries. The starting address
for the VisIt libraries using the current assumptions would then be:
0x22605000 + 10Mb
hrchilds's avatar
hrchilds committed
668 669

# Next offset
hrchilds's avatar
hrchilds committed
670
offset = 0x22605000 + 0x2faf080
hrchilds's avatar
hrchilds committed
671 672 673
# Align the offset to 0x1000 byte boundaries
offset = offset + (0x1000 - offset % 0x1000)
# Next offset
hrchilds's avatar
hrchilds committed
674
offset = 0x22f8f000
hrchilds's avatar
hrchilds committed
675

hrchilds's avatar
hrchilds committed
676 677 678 679 680 681
VisIt uses GNU's autoconf system to provide platform independence when
building VisIt in a UNIX environment. Autoconf creates a script called
configure that tests your system for various libraries and programs required
to build VisIt.  Follow the directions listed below to build VisIt.
More information about building VisIt follows after that.

hrchilds's avatar
hrchilds committed
682 683 684
#
# Unzipping VisIt's source code distribution
#
hrchilds's avatar
hrchilds committed
685 686 687
gunzip visit050516.tar.gz
tar xf visit050516.tar
cd visit050516
hrchilds's avatar
hrchilds committed
688

hrchilds's avatar
hrchilds committed
689 690 691 692 693 694 695 696 697 698 699 700 701 702
#
# HDF5 and Silo
#
If you built the Silo library with support for HDF5 using the instructions in
this document then you will need to modify VisIt's configure script somewhat so
programs that require the silo library also get linked with the HDF5 library.
On most other platforms, the Silo library is a static archive with the HDF5
symbols linked into it. These build instructions for MacOS X build Silo as a
dynamic, prebound library using a dynamic HDF5 library.

vi configure
replace -lsilo with: -lsilo -lhdf5
save and quit

hrchilds's avatar
hrchilds committed
703
#
hrchilds's avatar
hrchilds committed
704
# Configure VisIt
hrchilds's avatar
hrchilds committed
705
#
hrchilds's avatar
hrchilds committed
706
cd config-site
hrchilds's avatar
hrchilds committed
707 708 709
echo VISITHOME=`cat ../../visitpath` > `hostname`.conf
cat Template.conf >> `hostname`.conf
cd ..
hrchilds's avatar
hrchilds committed
710 711
env CXXFLAGS="-O2" ./configure

hrchilds's avatar
hrchilds committed
712 713 714 715 716 717 718
#
# If VisIt failed to configure properly, check the contents of the
# `hostname`.conf file to make sure that it points to the libraries that
# you build. You can look at whitestar.conf, which is a configuration file
# for another MacOS X computer, if you want an example file that works.
#

hrchilds's avatar
hrchilds committed
719 720 721 722 723 724
# Change the Silo optimization level.
The Silo database reader plugin fails to build on MacOS X with GCC3.3 because
it runs out of memory with the default -O2 optimization flag.

cd databases/Silo
vi Makefile
hrchilds's avatar
hrchilds committed
725 726 727 728 729
# Look for CXXFLAGS=$(CXXFLAGSORIG) and right after $(CXXFLAGSORIG), add -O1
# so the Silo database reader can build. The default optimization level (-O2)
# causes gcc to run out of memory on some MacOS X computers.


hrchilds's avatar
hrchilds committed
730 731
cd ../..

hrchilds's avatar
hrchilds committed
732

hrchilds's avatar
hrchilds committed
733 734
# Build VisIt
make
hrchilds's avatar
hrchilds committed
735 736

If you have any problems send e-mail to visit-help@llnl.gov.