import raylibpy -> "wrong ELF class: ELFCLASS32"
Closed this issue · 8 comments
I'm getting an error when I use "import raylibpy". I think it built a 32-bit library when it should be using 64-bit?
Traceback (most recent call last): File "./raylib_project.py", line 3, in <module> import raylibpy as raylib File "/usr/lib/python3.7/site-packages/raylib_py-0.1.1-py3.7.egg/raylibpy/__init__.py", line 71, in <module> _rl = CDLL(os.path.join(RAYLIB_BIN_PATH, _lib_filename[_platform])) File "/usr/lib/python3.7/ctypes/__init__.py", line 356, in __init__ self._handle = _dlopen(self._name, mode) OSError: /usr/lib/python3.7/site-packages/raylib_py-0.1.1-py3.7.egg/raylibpy/libraylib.so.2.0.0: wrong ELF class: ELFCLASS32
OS: Manjaro Linux (64-bit)
Both AUR and setup.py installations have same error.
Any ideas?
Hi, @flipcoder! Sorry for the late response.
The binaries that comes with raylib-py are all 32bit. But you can provide the 64bit version (from raylib repo or a custom one); all you have to do is replace it in the package folder or specify its location before importing raylib-py, as explained in the README.
Does this solve your problem?
If you used a package manager to install raylib, you need to figure out where the binary (libraylib.so.2.0.0) was installed, then set the environment variable to point to it (as described in the README):
import os
os.environ["RAYLIB_LIB_PATH"] = "/path/to/the/binary" # do this before importing raylib
import raylibpyThanks for the responses. I continued getting the same error after setting the environment, and it appears the readme method no longer works. Luckily I found a solution. Here are the details:
~/Projects/ray% file libraylib.so.2.0.0.
libraylib.so.2.0.0: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=6df240c34fd8d0eca39dee5dda43d240cea6bbe9, stripped
~/Projects/ray% ./raylib_project.py
Traceback (most recent call last):
File "./raylib_project.py", line 4, in <module>
import raylibpy
File "/usr/lib/python3.7/site-packages/raylib_py-0.1.1-py3.7.egg/raylibpy/__init__.py", line 71, in <module>
_rl = CDLL(os.path.join(RAYLIB_BIN_PATH, _lib_filename[_platform]))
File "/usr/lib/python3.7/ctypes/__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/python3.7/site-packages/raylib_py-0.1.1-py3.7.egg/raylibpy/libraylib.so.2.0.0: wrong ELF class: ELFCLASS32
raylib_project.py:
#!/usr/bin/python
import os, sys
os.environ['RAYLIB_LIB_PATH'] = '__main__'
import raylibpy
Same with when I try to load from /usr/lib/:
#!/usr/bin/python
import os, sys
os.environ['RAYLIB_LIB_PATH'] = '/usr/lib/'
import raylibpy
Making sure it's 64-bit:
~/Projects/ray% file /usr/lib/libraylib.so.2.0.0
/usr/lib/libraylib.so.2.0.0: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=6df240c34fd8d0eca39dee5dda43d240cea6bbe9, stripped
Setting 'RAYLIB_BIN_PATH' (instead of LIB) seems to work, so the readme appears to be incorrect.
Here's what worked:
import os, sys
os.environ['RAYLIB_BIN_PATH'] = '/usr/lib/'
import raylibpy
Thanks again for the help.
Cool, I'm glad it worked.
I'm confused by the issue with the environment variable. I just ran this on macOS, and it works perfectly:
import os
homebrew_raylib_binary = "/usr/local/Celler/raylib/2.0.0/lib/librarylib.2.0.0.dylib"
os.environ["RAYLIB_LIB_PATH"] = homebrew_raylib_binary
import raylibpy as ray
print(ray)@overdev seems pretty responsive, so hopefully he will drop in here again before long.
I just tried os.environ["RAYLIB_BIN_PATH"] on macOS, and it worked the same as with os.environ["RAYLIB_LIB_PATH"].
@overdev, are we confusing raylib and raylib-py environment variables?
It seems RAYLIB_BIN_PATH is the one used:
https://github.com/overdev/raylib-py/blob/master/raylibpy/__init__.py#L50
Hey, @flipcoder. Yep, you're right. The README will need updating.
Is the library generally working for you now? I'm on macOS, and it isn't working at all, but I don't think Macs are especially popular in the Raylib community, so Linux tends to work better.
My end goal is to use Raylib on a RPi, with RaylibPy providing CPython bindings for lighter stuff, so just need everything to work on Linux really.
@carlsmith Yes things are working with the solutions above so far (just tried a basic program). See my post on issue #6.