title: Building and running llvm-py on Mac OS X
body: <p>I was trying to build <a href="http://www.mdevan.org/llvm-py/" rel="nofollow">llvm-py</a> on Mac OS X.</p>
  
  <p>This is what I tried to do, I needed to download 11vm-2.7, and the README file has this comment: Make sure '--enable-pic' is passed to LLVM's 'configure'</p>
  
  <ol>
  <li>Download <a href="http://llvm.org/releases/2.7/docs/ReleaseNotes.html" rel="nofollow">llvm 2.7</a>.</li>
  <li>Build llvm 2.7: Run <code>./configure --prefix=LLVM_DIRECTORY --enable-pic</code></li>
  <li>Download <a href="http://www.mdevan.org/llvm-py/download.html" rel="nofollow">llvm-py 0.6</a>.</li>
  <li>Build llvm-py 0.6: Run <code>python setup.py build --llvm-config=LLVM_DIRECTORY/bin/llvm-config</code></li>
  </ol>
  
  <p>Everything compiles without errors, but when I tried to run test file, I got this error message. </p>
  
  <p><code>ImportError: 'dlopen(/Library/Python/2.7/site-packages/llvm/_core.so, 2): Symbol not found: __ZTVN4llvm16ExtractValueInstE\n Referenced from: /Library/Python/2.7/site-packages/llvm/_core.so\n Expected in: flat namespace\n in /Library/Python/2.7/site-packages/llvm/_core.so'</code></p>
  
  <p>The message error seems to say that there is a missing function "llvmExtractValueInst" with flat namemspace issue. What's wrong with this?</p>
  
  <p>In llvm 2.7, the Makefile.rules has this line</p>
  
  <p><code>SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
                      -dynamiclib</code></p>
  
  <p>I tried to remove the <code>flat_namespace</code>, but I got compilation error.</p>
  
  <h2>ADDED</h2>
  
  <p>Following locojay's answer, I could build brew and llvmpy.</p>
  
  <pre><code>export REQUIRES_RTTI=1
  brew install llvm --rtti
  sudo pip install git+https://github.com/llvmpy/llvmpy
  </code></pre>
  
  <p>However, when I tried to execute the examples in the test directory, I still got different kind of error-</p>
  
  <pre><code>test&gt; python example.py 
  Traceback (most recent call last):
    File "example.py", line 4, in &lt;module&gt;
      from llvm import *
    File "/Library/Python/2.7/site-packages/llvm/__init__.py", line 11, in &lt;module&gt;
      from llvm import _core
  ImportError: dlopen(/Library/Python/2.7/site-packages/llvm/_core.so, 2): Symbol not found: __ZN4llvm10DataLayout2IDE
    Referenced from: /Library/Python/2.7/site-packages/llvm/_core.so
    Expected in: flat namespace
   in /Library/Python/2.7/site-packages/llvm/_core.so 
  </code></pre>
  
  <p>This is the result when I run <code>otool -L /Library/Python/2.7/site-packages/llvm/_core.so</code></p>
  
  <pre><code>/Library/Python/2.7/site-packages/llvm/_core.so:
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
  /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
  </code></pre>