qilingframework / qiling

A True Instrumentable Binary Emulation Framework
https://qiling.io
GNU General Public License v2.0
5.06k stars 737 forks source link

ERROR: fail to load the dynamic library #1474

Open Hexix23 opened 3 months ago

Hexix23 commented 3 months ago

*Describe the bug Im having the following issue on MacOS Sonoma 14.5 everytime Im trying to run qltool.

Sample Code

python qltool
Traceback (most recent call last):
  File "/Users/0xh3l1x/Tools/Emulation/qiling/qltool", line 19, in <module>
    from qiling.arch import utils as arch_utils
  File "/Users/0xh3l1x/Tools/Emulation/qiling/qiling/arch/utils.py", line 14, in <module>
    from keystone import (Ks, KS_ARCH_ARM, KS_ARCH_ARM64, KS_ARCH_MIPS, KS_ARCH_X86, KS_ARCH_PPC,
  File "/Users/0xh3l1x/.pyenv/versions/3.10.14/lib/python3.10/site-packages/keystone/__init__.py", line 4, in <module>
    from .keystone import Ks, ks_version, ks_arch_supported, version_bind, debug, KsError, __version__
  File "/Users/0xh3l1x/.pyenv/versions/3.10.14/lib/python3.10/site-packages/keystone/keystone.py", line 74, in <module>
    raise ImportError("ERROR: fail to load the dynamic library.")
ImportError: ERROR: fail to load the dynamic library.

Additional context I know that the issue is described on https://github.com/qilingframework/qiling/issues/18 but didnt work.

I already installed also keystone-engine from source and didnt fix it anything

Thanks for the help, will be awesome to fix this :)

farss commented 3 weeks ago

Try view this: file /Users/0xh3l1x/.pyenv/versions/3.10.14/lib/python3.10/site-packages/keystone/libkeystone.dylib And: file $(which python)

Is there an incompatible architecture? If true, build and install keystone for arm64 manually. See https://github.com/keystone-engine/keystone/blob/master/docs/COMPILE-NIX.md

cmake -DBUILD_LIBS_ONLY=$BUILD_LIBS_ONLY -DLLVM_BUILD_32_BITS="$LLVM_BUILD_32_BITS" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=$BUILDTYPE -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="ARM;X86" -G "Unix Makefiles" ..

make -j8
sudo make install

When get this:

 file /usr/local/lib/libkeystone.dylib
/usr/local/lib/libkeystone.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
/usr/local/lib/libkeystone.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/lib/libkeystone.dylib (for architecture arm64):  Mach-O 64-bit dynamically linked shared library arm64

It's fine