Symbol Undefined...
See original GitHub issueI have read multiple examples for generating an so library using cython’s pure python interface, and then later calling a function in it. THE FUNCTION IS NOT GETTING DEFINED IN THE SO!
- The pure python code:
#cython: language_level=3
import cython
@cython.cfunc
@cython.returns(cython.int)
@cython.locals(a=cython.int)
def blah(a):
return 42
- The cython command:
cython3 test.py
- The gcc step:
gcc -fpic `python3-config --cflags` -o test.o -c test.c
- generate an so from the compilation output:
gcc -shared -o test.so test.o `python3-config --libs`
- List the entrypoints in the so:
nm -D test.so|less
# (I'm not seeing the function "blah" there!)
- Try accessing the so:
python3
from ctypes import CDLL
so=CDLL('./test.so')
dir(so)
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_flags_', '_func_restype_', '_handle', '_name']
# NO "blah" function!
All the pure python examples take it as a given that it will show up.
cython version: 0.29.30 python version: 3.9.2 gcc version: 10.2.1 ctypes version: 1.1.0 OS: Debian 11
Issue Analytics
- State:
- Created a year ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Undefined Symbols (Linker and Libraries Guide)
These symbol references are referred to as undefined symbols. Undefined symbols can affect the link-edit process according to the type of symbol, together...
Read more >c++ undefined symbol when compiling - Stack Overflow
I get the feeling that it's something really simple, but I can't seem to figure it out. c++ · compiler-errors · makefile ·...
Read more >What is the maths symbol for undefined? - Quora
There is no generally accepted symbol for "undefined." In math, this term refers to a value that is not assigned to any specific...
Read more >undefined symbol - C++ Forum
It means you haven't written a function, or you haven't created a variable, or you haven't linked against the library or object code...
Read more >What is the symbol for undefined? - Math Stack Exchange
According to Math - Symbol for Undefined, dividing a number by 0 may be represented by UNDEF, but the staff are unaware of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So to generate an so, I guess I want to do the setup.py with the cythonize call.
They are doing it with a pyx for input; can I pass a pure-python py file?
[I found 2 online examples doing it the gcc way I listed above; I figured once you have the c file generated by cython, the function call representing the call to the python function should be exposed thanks to those decorators I used above and found online…]
python setup.py build_ext --inplace test.py
And: thanks so far…
There’s a “public” modifier to expose symbols. Not sure if that’s available in Python code or limited to Cython syntax, though.