My environment is:
$ uname -a
Darwin taehun-gim-ui-MacBook-Pro.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
$ port list llvm
llvm @2.7 lang/llvm
I installed LLVM with MacPorts. I downloaded llvm-py 0.6 release and built it as in the user guide, but import llvm.core failed.
$ python
Python 2.6.1 (r261:67515, Dec 17 2009, 00:59:15)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import llvm.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kth3321/.local/lib/python2.6/site-packages/llvm/core.py", line 38, in <module>
import llvm._core as _core # C wrappers
ImportError: dlopen(/Users/kth3321/.local/lib/python2.6/site-packages/llvm/_core.so, 2): Symbol not found: _ffi_type_double
Referenced from: /Users/kth3321/.local/lib/python2.6/site-packages/llvm/_core.so
Expected in: flat namespace
in /Users/kth3321/.local/lib/python2.6/site-packages/llvm/_core.so
Looking at setup.py, call_setup reads the output of llvm-config --ldflags, but the result is not used anywhere. On my machine:
$ llvm-config --ldflags
-L/opt/local/lib -lpthread -lffi -lm
So I changed:
--- setup.py.orig 2010-09-26 15:46:33.000000000 +0900
+++ setup.py 2010-09-26 15:46:45.000000000 +0900
@@ -84,7 +84,7 @@
'instrumentation', 'ipa', 'ipo', 'transformutils',
'asmparser', 'linker', 'support'])
- std_libs = [ 'pthread', 'm', 'stdc++' ]
+ std_libs = [ 'pthread', 'm', 'stdc++', 'ffi' ]
if not ("openbsd" in sys.platform or "freebsd" in sys.platform):
std_libs.append("dl")
And after that it worked fine.
How should this be fixed the right way?
- Taehun Kim