exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
14.99k stars 516 forks source link

Using codon to call functions from dynamic library #125

Closed sDos280 closed 1 year ago

sDos280 commented 1 year ago

hi, 👋. some background: i am the developer of raypyc (the python binding for the raylib graphics library), some days ago someone told be about the codon project, so i ask my self "why not making a codon binding for raylib"? i am currently trying to use codon to call functions from dynamic library but it seem that whatever i do codon just can't find my dynamic library my script:

LIBRARY = "libraylib.so"

from C import LIBRARY.SetTargetFPS(int)

SetTargetFPS(600)

the build commend that i use: codon run -l "/home/dor/Documents/testing/libraylib.so" main.codon.

the tree of my project:

.
├── libraylib.so
└── main.codon

the dynamic library: https://github.com/sDos280/raylib-python-ctypes/blob/main/raypyc/libs/libraylib.so

the error:

CError: libraylib.so: cannot open shared object file: No such file or directory

Raised from: std.internal.dlopen.dlopen.2:0
/home/dor/.codon/lib/codon/stdlib/internal/dlopen.codon:31:9

Backtrace:
  [0x7f4253f8790f] GCC_except_table48 at /home/dor/.codon/lib/codon/stdlib/internal/dlopen.codon:31:9
  [0x7f4253f87977] GCC_except_table48 at /home/dor/.codon/lib/codon/stdlib/internal/dlopen.codon:28:46
  [0x7f4253f88ca6] GCC_except_table48 at /home/dor/Documents/testing/main.codon:3:1
Aborted (core dumped)

can i get some help on "how to setup codon dynamic linking"?

sDos280 commented 1 year ago

ummm, it seem that when i do LIBRARY = "./libraylib.so"and just run codon run main.codon it works...

sDos280 commented 1 year ago

ok, now i get raylib error (which need that i loaded the dynamic library currently, Yay). thanks for the awesome project.