[Error] Undefined Symbol when using @codon.jit for Python decorator
I follow the instructions here to try to use codon in Python codebase. I already installed codon in my installation dir MY_CODON_DIR, and MY_CODON_DIR/bin/codon is the executable. I can also run the codon commands directly in the CLI. But I failed to use @codon.jit for Python decorator.
This library will attempt to use an installed version of Codon. If Codon is installed at a non-standard path, set the CODON_DIR environment variable to the installation path.
I pip install codon-jit in my conda environment, and set the env variable CODON_DIR to MY_CODON_DIR, but running that demo python demo.py doesn't work. The error information is as follows:
Traceback (most recent call last):
File "codon_jit.py", line 4, in <module>
import codon
File "MY_CONDA_ENV_DIR/lib/python3.8/site-packages/codon/__init__.py", line 5, in <module>
from .decorator import jit, convert, JITError
File "MY_CONDA_ENV_DIR/lib/python3.8/site-packages/codon/decorator.py", line 17, in <module>
from .codon_jit import JITWrapper, JITError, codon_library
ImportError: MY_CONDA_ENV_DIR/lib/python3.8/site-packages/codon/codon_jit.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN5codon3jit7jitInitERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Do you know what happened? Thanks
If you build codon your self from source and then build the python plugin from the codon dir, it works if you specify clang++ as C compiler.
cd python
CC=clang++ python setup.py install
If you build codon your self from source and then build the python plugin from the codon dir, it works if you specify clang++ as C compiler.
cd python CC=clang++ python setup.py install
Hi, I didn't build codon from source. I followed this /bin/bash -c "$(curl -fsSL https://exaloop.io/install.sh)" to download and install. It's installed automatically into ~/.codon.
I tried to use CC=clang++ python setup.py install or pip install . under the ~/.codon/python dir, but the undefined symbol error is still the same.
the CODON_DIR environment variable is set to ~/.codon. I also tried a few other directories, e.g. ~/.codon/python, but it doesn't work. Could the problem be the wrong way of setting the env variable?
You need to compile codon from the last git source as the 0.15.2 release doesn't have the correct symbol needed by the python codon-jit module.
Working on it. Which OS / environment are you using, please?
Ok I see.
Working on it. Which OS / environment are you using, please?
I'm using Ubuntu 20.04.5 LTS. Conda environment.
I have similar problem that was not solved using solutions mentioned above.
file name: demo.py
import codon
$ python demo.py
libc++abi: terminating with uncaught exception of type codon::exc::ParserException: cannot locate standard library
I use MacOS (Apple M1 Pro) System Version: macOS 13.0 (22A380) Kernel Version: Darwin 22.1.0
codon version: 0.15.2
python version: 3.9.13
Those should be fixed in #119--- will be merged & released soon. Thank you for the reports!
This should be fixed now in the latest release (0.15.3). For the "cannot locate standard library" error, you can set the CODON_PATH environment variable to the standard library path. For example, for me would be:
export CODON_PATH=/Users/arshajii/.codon/lib/codon/stdlib
Please let us know if there are any other issues with this!
Oh, please also update the codon-jit package to the latest version (0.1.1).
It works for me now. Thanks!