Building Freesurfer on Mountain Lion

This document is an account of my attempt to make Hima a daily build platform for building a 64bit version of Freesurfer running on Mac OSX Mountain Lion.

Download the source code

>> cd /space/freesurfer/build/hima/stable/dev
>> cvs checkout -P -r stable5 dev

./setup_configure

>> cd dev
>> ./setup_configure
rm -rf autom4te.cache
glibtoolize --force
glibtoolize: Command not found.

This was fixed by adding to my PATH:

>> export PATH=$PATH:/usr/pubsw/packages/autotools/bin/

Trying ./setup_configure again revealed more issues:

>> ./setup_configure
rm -rf autom4te.cache
glibtoolize --force
You should add the contents of `/usr/pubsw/packages/autotools/share/aclocal/libtool.m4' to `aclocal.m4'.
Putting files in AC_CONFIG_AUX_DIR, `config'.
aclocal
autom4te: need GNU m4 1.4 or later: /usr/bin/gm4
aclocal: autom4te failed with exit status: 1

This was fixed by installing XCode 4.5.1 Command Line Tools:

Completes!

./configure

>> ./configure --prefix=/usr/local/freesurfer/stable --disable-all-apps
.
.
.
configure: error: FATAL: A Fortran 77 compiler is required!

Installed gfortran.

Trying again:

>> ./configure --prefix=/usr/local/freesurfer/stable --disable-all-apps
.
.
.
FreeSurfer is now configured for i386-apple-darwin12.2.0

  Source directory:  .
  Build directory:   /Users/Shared/nightly_build/stable/dev
  Install directory: /usr/local/freesurfer/dev

  C compiler:   gcc -gfull -O3 -msse2 -mfpmath=sse -Wall -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -m64 -DDarwin -DANSI  -I/usr/pubsw/packages/mni/current/include
  C++ compiler: g++ -gfull -O3 -msse2 -mfpmath=sse -Wall -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -m64 -DDarwin -DANSI  -I/usr/pubsw/packages/mni/current/include
  Fortran:      gfortran -g -O2
  Linker:       /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld  -dead_strip   -L/usr/pubsw/packages/mni/current/lib -L/usr/pubsw/packages/vxl/current/lib  -L/usr/pubsw/packages/itk/current/lib/InsightToolkit
  Libs:           /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKIO.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKAlgorithms.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKCommon.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKNumerics.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKMetaIO.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKniftiio.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKNrrdIO.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkpng.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitksys.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitktiff.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkv3p_netlib.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkzlib.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkgdcm.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkopenjpeg.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkjpeg8.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkjpeg12.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libitkjpeg16.a   /usr/pubsw/packages/itk/current/lib/InsightToolkit/libITKDICOMParser.a  -lz -lm  -ldl -lpthread     -lnetcdf -lvolume_io -lminc -lvnl_algo -lvnl -lvcl -lnetlib -lv3p_netlib

Completes!

make

>> make -j9

The following table lists the packages I had to remove from the Makefile in order to build to completion:

Package

Error Message

comment

opencl_algorithms

../config.h:340:1: error: "PTHREAD_CREATE_JOINABLE" redefined

Solved by commenting out "#define PTHREAD_CREATE_JOINABLE $ok" from autogenerated config.h file. (Autotools wierdness)

nmovies

nmovie.c:47:22: error: X11/Xlib.h: No such file or directory

Solved by adding "$(GL_CFLAGS)" and $(HAVE_OPENGL) to AM_CPPFLAGS in nmovies/Makefile

mri_ca_register

mri_ca_register.c:1256: warning: call to \_\_builtin\_\_\_memmove_chk will always overflow destination buffer

Solved by removing -Werror flag from mri_ca_register/Makefile

mri_robust_register

ld: framework not found veclib

Solved by replacing "-framework veclib" with "-framework vecLib" in mri_robust_register/Makefile

talairach_avi

ld: symbol(s) not found for architecture x86_64

Solved by uncommenting all lines with -DHAVE_GFORTRAN in file talairach_avi/Makefile

mris_pmake

../config.h:340:1: error: "PTHREAD_CREATE_JOINABLE" redefined

Solved by technique above with opencl_algorithms

GEMS

kvlAtlasMeshBuilder.cxx:3723: error: ‘isnan’ was not declared in this scope

Solved by changing isnan to std::isnan in file kvlAtlasMeshBuilder.cxx

fem_elastic

ld: library not found for -llmpe

??

trc

../fem_elastic/libfem_elastic.a', needed by dmri_trk2trk.

Needs fem_elastic

With the packages above commented out of the Makefile, make runs to completion.

make install

Make install errors out with a segmentation fault.

>> make install
.
.
.
make  install-exec-hook
cp ./unpacksdcmdir /usr/local/freesurfer/stable/bin/unpacksdcmdir.tcl
echo "#!/bin/tcsh -ef" \
                > /usr/local/freesurfer/stable/bin/unpacksdcmdir
echo "source \$FREESURFER_HOME/bin/tcl_setup" \
                >> /usr/local/freesurfer/stable/bin/unpacksdcmdir
echo "\$FREESURFER_HOME/lib/tcltktixblt/bin/tclsh8.4 \$FREESURFER_HOME/bin/unpacksdcmdir.tcl \$argv" \
                >> /usr/local/freesurfer/stable/bin/unpacksdcmdir
chmod a+x /usr/local/freesurfer/stable/bin/unpacksdcmdir
cp ./fsfget /usr/local/freesurfer/stable/bin/fsfget.tcl
echo "#!/bin/tcsh -ef" \
                > /usr/local/freesurfer/stable/bin/fsfget
echo "source \$FREESURFER_HOME/bin/tcl_setup" \
                >> /usr/local/freesurfer/stable/bin/fsfget
echo "\$FREESURFER_HOME/lib/tcltktixblt/bin/tclsh8.4 \$FREESURFER_HOME/bin/fsfget.tcl \$argv" \
                >> /usr/local/freesurfer/stable/bin/fsfget
chmod a+x /usr/local/freesurfer/stable/bin/fsfget
../utils/fsPrintHelp ./bbregister.help.xml >> /usr/local/freesurfer/stable/bin/bbregister
/bin/sh: line 1: 17021 Segmentation fault: 11  ../utils/fsPrintHelp ./bbregister.help.xml >> /usr/local/freesurfer/stable/bin/bbregister
make[3]: *** [install-exec-hook] Error 139
make[2]: *** [install-exec-am] Error 2
make[1]: *** [install-am] Error 2
make: *** [install-recursive] Error 1

Uggghhh! X-(

fsPrintHelp is prone to segmentation faults. By commenting out its usage in the Makefile of the scripts and mri_cvs_register packages, I am able to get make_install to run to completion. But the recon-all script requires the talairch_avi binary so I am stuck until I get that at least that directory to compile.

MountainLionBuild (last edited 2012-11-09 18:08:14 by ZekeKaufman)