Python Extension with openmp in OS X
<p>I have created a python extension that works correctly in Linux but doesn't work in os x.</p>

<p>The C code makes use of the openmp library.</p>

<p>The C compiler that is preinstalled in os x is clang and the preinstalled python has been built with clang. That clang doesn't support openmp.</p>

<p>I can compile and run my code by installing gcc-6 by:</p>

<pre><code>    brew install gcc
</code></pre>

<p>I can build my libary by including in the file setup.py the environment variable CC:</p>

<pre><code>    os.environ["CC"]="/usr/local/Cellar/gcc/6.2.0/bin/gcc-6"
</code></pre>

<p>And I include the gcc library path in the setup configuration:</p>

<pre><code>    library_dirs = ["/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/","../build/"],
</code></pre>

<p>But then I obtain errors when I load my library from python:</p>

<pre><code>    import myLibraryName
</code></pre>

<p>ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/LIBIRWLS.so, 2): Symbol not found: ___emutls_get_address
  Referenced from: /usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib</p>

<p>What should I do? What is the correct procedure create a python extension in OS X that makes use of the openmp library?</p>