Slicer:Slicer2.5 Patches for the Mac

From Slicer Wiki
Jump to: navigation, search
Home < Slicer:Slicer2.5 Patches for the Mac

Note: These instructions refer to the steps needed to compile the 2.5 release of Slicer on OSX 10.3 (Panther) and 10.4 (Tiger). Check the nightly cvs for the most recent Mac patches, and watch this space for updates.

General Information

We are currently compiling on the Mac with gcc 3.3. The current developer's kit comes with gcc 4.0, so you may have to obtain an earlier version of gcc to get Slicer and its supporting libraries to compile.

You can make gcc 4.0 behave as an earlier version by using gcc_select (assuming your account is enabled to administer the computer):


sudo gcc_select 3.3

CMake

If CMake fails during its bootstrapping process, try setting the following environment variables:


export CC="/usr/bin/gcc"
export CXX="/usr/bin/g++"

VTK

If VTK is failing with the following error:


ld: Undefined symbols:  __ZNSt8ios_base4InitC4Ev

there are a couple of things to look at. First of all, make sure you are using gcc version 3.x. This symbol is undefined in gcc versions 2 and 4. Also, make sure that you're actually using gcc and g++ instead of gcc and c++ for compilers. Look at the CMake command used to compile VTK. If it is using c++ instead of g++, you will see something like the following:


 /Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/CMake-build/bin/cmake {-GUnix Makefiles} -DCMAKE_BUILD_TYPE:STRING= -DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_CXX_COMPILER:STRING=/usr/bin/c++ -DCMAKE_CXX_COMPILER_FULLPATH:FILEPATH=/usr/bin/c++ -DBUILD_TESTING:BOOL=OFF -DVTK_USE_CARBON:BOOL=OFF
-DVTK_USE_X:BOOL=ON -DVTK_WRAP_TCL:BOOL=ON -DVTK_USE_HYBRID:BOOL=ON -DVTK_USE_PATENTED:BOOL=ON
-DTCL_INCLUDE_PATH:PATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/include
-DTK_INCLUDE_PATH:PATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/include
-DTCL_LIBRARY:FILEPATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/lib/libtcl8.4.so
-DTK_LIBRARY:FILEPATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/lib/libtk8.4.so
-DTCL_TCLSH:FILEPATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/bin/tclsh8.4 {} ../VTK

To fix this, you can either edit the CMakeLists.txt file to change the CXX compiler string and path and rebuild VTK, or cd to the VTK-build directory, edit the command to refer to /usr/bin/g++ instead of /usr/bin/c++, and rerun the cmake and make commands:


cd Lib/darwin-ppc/VTK-build

/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/CMake-build/bin/cmake {-GUnix Makefiles} -DCMAKE_BUILD_TYPE:STRING= -DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++ -DCMAKE_CXX_COMPILER_FULLPATH:FILEPATH=/usr/bin/g++ -DBUILD_TESTING:BOOL=OFF -DVTK_USE_CARBON:BOOL=OFF
-DVTK_USE_X:BOOL=ON -DVTK_WRAP_TCL:BOOL=ON -DVTK_USE_HYBRID:BOOL=ON -DVTK_USE_PATENTED:BOOL=ON
-DTCL_INCLUDE_PATH:PATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/include
-DTK_INCLUDE_PATH:PATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/include
-DTCL_LIBRARY:FILEPATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/lib/libtcl8.4.so
-DTK_LIBRARY:FILEPATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/lib/libtk8.4.so
-DTCL_TCLSH:FILEPATH=/Users/slicer/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl-build/bin/tclsh8.4 {} ../VTK

make -j4

to build VTK by hand. (Substitute directory names as appropriate for your build.)

ITK

If the ITK build is failing with a "Dunno about this gcc" error, it might be using the /usr/bin/c++ compiler instead of the /usr/bin/g++ compiler. You can fix this with the same steps as used above in the VTK example.

BLT

Currently, BLT fails during the 'make install' step for the Mac. When you start Slicer, you will get the following error message: "Must have BLT package for building fMRIEngine UI and plotting time course."

Building and patching BLT on the Mac is no fun, but the following instructions aim to document every painful step. The instructions assume that you do not change directories except when explicitly indicated. So, put on your pointy hat and:

  • cd slicer2
  • Run Scripts/genlib.tcl and Scripts/cmaker.tcl all the way through.
  • cd Lib/darwin-ppc/tcl
  • Remove an existing BLT:


rm -rf blt
  • Do a fresh CVS checkout of BLT (you should be in the slicer2/Lib/darwin-ppc/tcl directory):


cvs -d :pserver:anonymous:bwhspl@cvs.spl.harvard.edu:/projects/cvs/slicer login
cvs -d :pserver:anonymous:bwhspl@cvs.spl.harvard.edu:/projects/cvs/slicer co -r blt24z blt
  • cd blt
  • Download the required patches:


curl -O http://easynews.dl.sourceforge.net/sourceforge/blt/blt2.4z-patch-1
curl -O http://easynews.dl.sourceforge.net/sourceforge/blt/blt2.4z-patch-2
  • Applying the patches is far from an automatic process, because of the way these patches were written. Until there is more time and demand to fix this, you have to do give some manual assistance. Start the first patch:


patch < blt2.4z-patch-1

It will come back with:

 can't find file to patch at input line 20
 Perhaps you should have used the -p or --strip option?
 The text leading up to this was:
 --------------------------
 |
 |This patch fixes the following problems with BLT 2.4z
 |
 |  1) BLT won't load into more than one interpreter.
 |
 |  2) Hiding an element
 |
 |        .graph element configure "e0" -hide yes
 |
 |    also hides the legend entry.
 |
 |Apply this patch from the top of the blt2.4z source tree (i.e.
 |the directory that contains "blt2.4z").
 |
 |  --gah
 |
 |diff -cr blt2.4z-old/src/bltGrAxis.c blt2.4z/src/bltGrAxis.c
 |*** blt2.4z-old/src/bltGrAxis.c        2002-09-18 17:30:51.000000000 -0500
 |--- blt2.4z/src/bltGrAxis.c    2002-12-02 22:39:26.000000000 -0600
 --------------------------
 File to patch:
 
  • You can ignore the "Perhaps you should have used the -p or --strip option?" messages
  • The required filename is identified in the last few lines:

|diff -cr blt2.4z-old/src/bltGrAxis.c blt2.4z/src/bltGrAxis.c
|*** blt2.4z-old/src/bltGrAxis.c 2002-09-18 17:30:51.000000000 -0500
|--- blt2.4z/src/bltGrAxis.c 2002-12-02 22:39:26.000000000 -0600
So at the "File to patch:" prompt, you enter this:


File to patch: ./src/bltGrAxis.c

and you should get:

 can't find file to patch at input line 270
 Perhaps you should have used the -p or --strip option?
 The text leading up to this was:
 --------------------------
 |diff -cr blt2.4z-old/src/bltGrElem.c blt2.4z/src/bltGrElem.c
 |*** blt2.4z-old/src/bltGrElem.c        2002-09-18 17:30:51.000000000 -0500
 |--- blt2.4z/src/bltGrElem.c    2002-12-02 22:42:31.000000000 -0600
 --------------------------
 File to patch:
 
  • Because bltGrElem.c is named in the second-to-last line, you enter:


File to patch: ./src/bltGrElem.c
  • This process continues for one more file, ./src/bltInit.c. In total, the first patch needs to be prompted for these files:
    • ./src/bltGrAxis.c
    • ./src/bltGrElem.c
    • ./src/bltInit.c
  • Now apply the second patch:


patch < blt2.4z-patch-2
  • You need to assist this patch in the same manner as above. This patch suffers the additional problem that it wants to re-apply some of the changes from the first patch, so you will see things like:


Reversed (or previously applied) patch detected!  Assume -R? [n]

at which point you type "yes" and hit return.

  • The second patch needs to be prompted for the following files. The ones for which you have to type "yes" to the above warning are indicated:
    • ./src/bltGrAxis.c ("yes")
    • ./src/bltGrElem.c ("yes")
    • ./src/bltGrMarker.c
    • ./src/bltInit.c ("yes")
    • ./src/bltTreeView.c
  • You have now finished patching BLT.
  • Still in the slicer2/Lib/darwin-ppc/tcl/blt directory, edit src/shared/Makefile.in to change the line:


LDFLAGS =	@LDFLAGS@ @LD_RUN_PATH@

to:


LDFLAGS =	@LDFLAGS@ @LD_RUN_PATH@ $(LIBS)
  • Change the environment variables CFLAGS and CXXFLAGS. For tcsh:


setenv CFLAGS "-fno-common"
setenv CXXFLAGS "${CFLAGS}"

or for bash:


export CFLAGS="-fno-common"
export CXXFLAGS="${CFLAGS}"
  • Run configure:


./configure --with-tcl=/Users/${USER}/slicer2/Lib/darwin-ppc/tcl/tcl/unix \
--with-tk=/Users/${USER}/slicer2/Lib/darwin-ppc/tcl-build \
--prefix=/Users/${USER}/slicer2/Lib/darwin-ppc/tcl-build

Note that the full pathnames are used (i.e. /Users/${USER}/slicer2 instead of ~/slicer2) because configure doesn't seem to parse the tilde correctly. The ${USER} environment variable may not be present in bash.

  • Built BLT:


make
make install
  • The make install will fail with this error message:


...
...
/Users/gk/slicer2/Lib/darwin-ppc/tcl/tcl/unix/libtcl8.4.dylib(tclStubLib.o) not from earlier dynamic library /Users/gk/slicer2/Lib/darwin-ppc/tcl-build/lib/libtk8.4.dylib(tclStubLib.o)
  /usr/bin/install -c -m 0755 bltwish24 /Users/gk/slicer2/Lib/darwin-ppc/tcl-build/bin
  /usr/bin/install -c -m 0755 bltsh24 /Users/gk/slicer2/Lib/darwin-ppc/tcl-build/bin
  install: bltsh24: No such file or directory
  make[2]: *** [install-demo] Error 71
  make[1]: *** [install-lib] Error 2
  make: *** [install-all] Error 2

which can be safely ignored- the necessary libraries have been created.

  • The end.