<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
<title>Build Notes for cctbx on OS X 10.7.5</title>
<style type="text/css">

/*
:Authors: Ian Bicking, Michael Foord
:Contact: fuzzyman@voidspace.org.uk
:Date: 2005/08/26 
:Version: 0.1.0
:Copyright: This stylesheet has been placed in the public domain.

Stylesheet for Docutils.
Based on ``blue_box.css`` by Ian Bicking
and ``html4css1.css`` revision 1.46.
*/

@import url(html4css1.css);

body {
  font-family: Arial, sans-serif;
}

em, i {
  /* Typically serif fonts have much nicer italics */
  font-family: Arial, sans-serif;
}

a.target {
  color: blue;
}

a.target {
  color: blue;
}


a.toc-backref {
  text-decoration: none;
  color: black;
}

a.toc-backref:hover {
  background-color: inherit;
}

a {
  text-decoration: none ;
}

a:visited {
  color: blue;
}

a:hover {
  color: #990000;
}

div.attention, div.caution, div.danger, div.error, div.hint,
div.important, div.note, div.tip, div.warning {
  background-color: #eeeeee ;
  width: 65% ;
}

div.attention > p.last, div.caution > p.last, div.danger > p.last,
div.error > p.last, div.hint > p.last, div.important > p.last,
div.note > p.last, div.tip > p.last, div.warning > p.last {
  padding: 5px 10px 2px 5px ;
  margin: 0px ;


div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title  {
  text-align: center;
  background-color: #cccccc;
  padding: 0px ;
  margin: 0px;
}

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
  color: #cc0000;
  font-family: sans-serif;
  text-align: center;
  background-color: #999999;
  display: block;
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: Helvetica, Arial, sans-serif;
  border: thin solid black;
  /* This makes the borders rounded on Mozilla, which pleases me */
  -moz-border-radius: 8px;
  padding: 4px;
}

h1 {
  background-color: #ddddaa;
  color: #222266;
  border: thin solid black;
  padding: 8px 4px 8px 4px;
  margin: 2em 0em 0.75em 0em;
}

h1 a.toc-backref, h2 a.toc-backref { 
  color: #ffffff;
}

h2 {
  /* background-color: #ffffff; */
  display : block ;
  color: #222266;
  border: none;
  padding: 4px 4px 4px 24px;
  margin: 20px 0px 2px 0px;
  text-decoration: underline;
}

h3, h4, h5, h6 {
  background-color: #cccccc;
  color: #000000;
}

h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref, 
h6 a.toc-backref { 
  color: #000000;
}

h1.title {
  text-align: center;
  -moz-border-radius: 20px;
}

table.footnote {
  padding-left: 0.5ex;
}

table.citation {
  padding-left: 0.5ex
}

div.section#synopsis {
  display : none ;
}

.norefs {
  display : none ;
}

.norefs > h1 {
  background-color : #eeccee ;
}


.low-priority {
  display : none ;
  background-color : #bbbbbb ;
  padding: 4px ;
  margin: 4px 0px 4px 0px ;
  border-style: solid ;
  border-color: #555555 ;
  color : #555555 ;
  border-width: 1px ;
}

.letters {
  display : none ;
  background-color : #ddeeff ;
  padding: 4px ;
  margin: 4px 0px 4px 0px ;
  border-style: solid ;
  border-color: #778899 ;
  border-width: 1px ;
}

.nothing {
  /* background-color : #ffddcc ; */
  padding: 4px ;
  margin: 4px 0px 4px 0px ;
  border-style: solid ;
  border-color: #998877 ;
  border-width: 1px ;
}

.app {
  /* background-color : #ffddcc ; */
  padding: 4px ;
  margin: 4px 0px 4px 0px ;
  border-style: solid ;
  border-color: #998877 ;
  border-width: 1px ;
}

.letters-app {
  display : none ;
  background-color : #eeeeee ;
  padding: 4px ;
  margin: 4px 0px 4px 0px ;
  border-style: solid ;
  border-color: #777777 ;
  border-width: 1px ;
}

th.field-name {
  text-align : right ;
}

li > dl {
  padding : 0px ;
  margin : 0px 4px 4px 0px ;
}


td ul {
  padding : 0px ;
  margin : 0px 4px 4px 0px ;
}

td > ul {
  /* border-style : solid ; */
  /* border-width : 0px 0px 0px 3px ; */
  /* padding : 0px 0px 0px 1.5em ; */
  margin-left : 2em ; 
  /* border-color : #ddddaa ; */
}
  

td > ul li > p:first-child {
  display : inline ;
}

div.line-block {
  border-style : solid ;
  border-width : 0px 0px 0px 3px ;
  padding : 2px 0px 2px 0.75em ;
  margin : 4px 0px 4px 0.5em ;
  border-color : #ddddaa ;
}

td.field-body > p:first-child {
  display : inline ;
}

pre.literal-block, pre.doctest-block {
  border: thin black solid;
  padding: 5px;
  margin-left: 2em;
  background: #ddeeff ;
}

.image img { border-style : solid;
            border-width : 2px;
}

h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
  font-size: 100%;
}

code, tt {
  color: #000066;
}


</style>
</head>
<body>
<div class="document" id="build-notes-for-cctbx-on-os-x-10-7-5">
<h1 class="title">Build Notes for cctbx on OS X 10.7.5</h1>

<p>These notes describe a successful build of cctbx against a specific python
interpreter, namely <a class="reference external" href="http://www.enthought.com/products/epd.php">Enthought python</a> 7.3-2 for x86_64.</p>
<p>Although working, versions of cctbx are available for both the system python or
with a dedicated python, these canned solutions are not optimal. First, it's not
advisable to modify system utilities. Although cctbx seems well-behaved in this
regard, other packages may not be so well behaved. Second, the canned approach
requires building many of the numerous packages that come with bundeld python
distributions like the Enthought distribution (some such packages exceed even
cctbx in their difficulty to build). Third, if every package required its own
python, every script would need to fire-up dozens of separate interpreters just
to do its job, resulting in significant computational overhead with consummately
slower execution times.</p>
<ol class="arabic">
<li><p class="first">The default c++ compiler for OS X 10.7 is actually clang (<tt class="docutils literal">/usr/bin/c++</tt>).
Using clang exposes invalid template code. The first of many errors is:</p>
<pre class="literal-block">
In file included from
/opt/cctbx/cctbx_sources/mmtbx/bulk_solvent/bulk_solvent_ext.cpp:7:
 /opt/cctbx/cctbx_sources/mmtbx/bulk_solvent/bulk_solvent.h:496:21:
error: call to function 'r_factor' that is neither visible in the template
  definition nor found by argument-dependent lookup
      r.push_back(r_factor(f_obs, f_model.const_ref()));
</pre>
<p>These types of errors are documented at the page
<a class="reference external" href="http://clang.llvm.org/compatibility.html#dep_lookup">http://clang.llvm.org/compatibility.html#dep_lookup</a></p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">The installation directory is <tt class="docutils literal">/opt/cctbx</tt>.</p>
</div>
</li>
<li><p class="first">I tried to use the HPC compilers at <a class="reference external" href="http://hpc.sourceforge.net/">http://hpc.sourceforge.net/</a>,
but they do not recognize the <tt class="docutils literal"><span class="pre">-no-cpp-precomp</span></tt> flag. The web page
<a class="reference external" href="https://svn.boost.org/trac/boost/ticket/6697">https://svn.boost.org/trac/boost/ticket/6697</a> suggests the problem is with
boost. However, according to the comments therein, this should have been
fixed in boost 1.50. I am building against boost 1.52. Perplexed about the
source of this compiler flag, I tracked it down to the file
<tt class="docutils literal">cctbx_sources/libtbx/SConscript</tt>, after spending much of a day learning how
scons goes about its business. There are two possible fixes:</p>
<ul>
<li><p class="first">Comment the following line in <tt class="docutils literal">cctbx_sources/libtbx/SConscript</tt>:</p>
<pre class="literal-block">
# env_etc.ccflags_base.extend([&quot;-no-cpp-precomp&quot;])
</pre>
</li>
<li><p class="first">Link <tt class="docutils literal">/usr/bin/g++</tt> to <tt class="docutils literal">c++</tt> in a way that it will be found first in the
path. For example:</p>
<pre class="literal-block">
% ln -s /usr/bin/g++ ${HOME}/bin/c++
</pre>
</li>
</ul>
</li>
<li><p class="first">I first fixed the <tt class="docutils literal"><span class="pre">-no-cpp-precomp</span></tt> error by the former, commenting the
offending line in <tt class="docutils literal">cctbx_sources/libtbx/SConscript</tt> but this failed
with the error:</p>
<pre class="literal-block">
/opt/cctbx/cctbx_sources/scitbx/array_family/memory.h:35:47:
error: operator '&amp;&amp;' has no right operand
#elif defined(_XOPEN_SOURCE) &amp;&amp; _XOPEN_SOURCE &gt;= 600 &amp;&amp; defined(_POSIX_ADVISORY_INFO)
                                              ^
</pre>
<p>The page <a class="reference external" href="http://forums.fedoraforum.org/archive/index.php/t-52929.html">http://forums.fedoraforum.org/archive/index.php/t-52929.html</a> suggests
that the naked <tt class="docutils literal">_XOPEN_SOURCE</tt> wrecks the conditional when <tt class="docutils literal">_XOPEN_SOURCE</tt> is
not defined. One possible way to overcome this problem is to change the offending
line into a nested if/then, hoping that the comparison never gets evaluated under
circumstances when <tt class="docutils literal">_XOPEN_SOURCE</tt> is not defined:</p>
<pre class="literal-block">
#elif defined(_XOPEN_SOURCE)

#if _XOPEN_SOURCE &gt;= 600 &amp;&amp; defined(_POSIX_ADVISORY_INFO)
#define SCITBX_AF_HAS_ALIGNED_MALLOC 1
#define SCITBX_AF_USE_POSIX_FOR_ALIGNED_MALLOC 1
#endif

#endif
</pre>
<p>However, this was unnecessary because the second fix to the <tt class="docutils literal"><span class="pre">-no-cpp-precomp</span></tt>
error (linking <tt class="docutils literal">/usr/bin/g++</tt> to <tt class="docutils literal">c++</tt>) worked and avoided changing the
preprocessor source.</p>
</li>
<li><p class="first">Left to its own devices, scons could not find my <tt class="docutils literal">fftw3.h</tt>, which I have
installed (via fink) to <tt class="docutils literal">/sw/include/fftw3.h</tt>. To fix this problem, I
inserted the second of the following two lines into the file
<tt class="docutils literal">cctbx_sources/libtbx/SConscript</tt>:</p>
<pre class="literal-block">
env_etc.ccflags_base.extend([&quot;-no-cpp-precomp&quot;])
env_etc.ccflags_base.extend([&quot;-I/sw/include&quot;])
</pre>
<p>Although this allowed scons to find the header, it could not find the actual
library, requiring the insertion of the second of the following lines into
the file <tt class="docutils literal">cctbx_sources/libtbx/SConscript</tt>:</p>
<pre class="literal-block">
env_etc.shlinkflags_bpl = [
   &quot;-L/sw/lib&quot;,
   &quot;-w&quot;, # suppress &quot;source/lib does not exist&quot; warning
   &quot;-bundle&quot;,
   &quot;-undefined&quot;, &quot;dynamic_lookup&quot;]
</pre>
</li>
</ol>
</div>
</body>
</html>