Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS Ventura 13.0.1 M1 - librtlsdr issue #76

Open
melidosian opened this issue May 25, 2023 · 0 comments
Open

Mac OS Ventura 13.0.1 M1 - librtlsdr issue #76

melidosian opened this issue May 25, 2023 · 0 comments

Comments

@melidosian
Copy link

I am trying to run a script rtl-sdr-close-call-monitor and I'm having trouble getting the dependencies working on my M1 Mac. I have installed all of the dependencies via numpy, playsound, pyrtlsdr, and requests via PIP3 and librtlsdr via brew. When I run the script, I get this error:
Traceback (most recent call last): File "/Users/charlesmelidosian/Documents/programming/rtl-sdr/freq-monitor/close-call/monitor_with_sound.py", line 4, in <module> from rtlsdr import RtlSdr File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/rtlsdr/__init__.py", line 56, in <module> from .librtlsdr import librtlsdr File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/rtlsdr/librtlsdr.py", line 52, in <module> librtlsdr = load_librtlsdr() ^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/rtlsdr/librtlsdr.py", line 47, in load_librtlsdr raise ImportError('Error loading librtlsdr. Make sure librtlsdr '\ ImportError: Error loading librtlsdr. Make sure librtlsdr (and all of its dependencies) are in your path

From my research, I need to add /usr/local/lib to $LD_LIBRARY_PATH and to $PATH, which I've done. Still, I get the same error. Checking in that directory, I have the following files:
la /usr/local/lib total 5936 [... unrelated files ...] -rwxr-xr-x@ 1 root wheel 51K May 24 21:03 librtlsdr.0.0.0.dylib -rwxr-xr-x@ 1 root wheel 51K May 24 21:03 librtlsdr.0.dylib -rwxr-xr-x@ 1 root wheel 51K May 24 21:03 librtlsdr.dylib -rwxr-xr-x 1 root wheel 2.5M Oct 18 2021 libsdrpp_core.dylib -rwxr-xr-x@ 1 root wheel 72K May 24 21:03 libusb-1.0.0.dylib

So I know I have the library file installed, and the path to the library is in both environment variables. Checking the librtlsdr.py library script I know that the driver is loaded with this code:
`def load_librtlsdr():
if sys.platform == "linux" and 'LD_LIBRARY_PATH' in os.environ.keys():
ld_library_paths = [local_path for local_path in os.environ['LD_LIBRARY_PATH'].split(':') if local_path.strip()]
driver_files = [local_path + '/librtlsdr.so' for local_path in ld_library_paths]
else:
driver_files = []
driver_files += ['librtlsdr.so', 'rtlsdr/librtlsdr.so']
driver_files += ['rtlsdr.dll', 'librtlsdr.so', 'librtlsdr.dylib']
driver_files += ['..//rtlsdr.dll', '..//librtlsdr.so']
driver_files += ['rtlsdr//rtlsdr.dll', 'rtlsdr//librtlsdr.so']
driver_files += [lambda : find_library('rtlsdr'), lambda : find_library('librtlsdr')]
dll = None

for driver in driver_files:
    if callable(driver):
        driver = driver()
    if driver is None:
        continue
    try:
        dll = CDLL(driver)
        break
    except:
        pass
else:
    raise ImportError('Error loading librtlsdr. Make sure librtlsdr '\
                      '(and all of its dependencies) are in your path')
return dll

librtlsdr = load_librtlsdr()`

If I run this excerpt in Python, I can reproduce the error. I modified the script it to remove the try/except and error message, I get this:
Traceback (most recent call last): File "/Users/charlesmelidosian/Documents/programming/rtl-sdr/freq-monitor/libsdrtest.py", line 42, in <module> librtlsdr = load_librtlsdr() ^^^^^^^^^^^^^^^^ File "/Users/charlesmelidosian/Documents/programming/rtl-sdr/freq-monitor/libsdrtest.py", line 31, in load_librtlsdr dll = CDLL(driver) ^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 376, in __init__ self._handle = _dlopen(self._name, mode) ^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: dlopen(/usr/local/lib/librtlsdr.dylib, 0x0006): tried: '/usr/local/lib/librtlsdr.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/librtlsdr.dylib' (no such file), '/usr/local/lib/librtlsdr.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

From that error, I know that it's an architecture issue with the library (have 'x86_64', need 'arm64') - but this is where I'm stuck. I have looked into compiling the library but have not been successful. When I try to compile it from source, I get this error:
[ 3%] Linking C shared library librtlsdr.dylib ld: library not found for -lusb-1.0 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [src/librtlsdr.0.6git.dylib] Error 1 make[1]: *** [src/CMakeFiles/rtlsdr.dir/all] Error 2 make: *** [all] Error 2

I read another issue that instructed me to use the make command make LIBRARY_PATH=/usr/local/lib, but I get the same error as before. As you can see from above, the libusb-1.0.0.dylib library file is present in /usr/local/lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant