尝试安装rtl-sdr
(通过git clone git://git.osmocom.org/rtl-sdr.git
)感谢此处的说明,但不能比make
第一个说明序列更进一步:
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
在我第一次尝试时,我收到以下错误:
/rtl-sdr/src/librtlsdr.c:30:10: fatal error: libusb.h: No such file or directory
找到此文件后:
/usr/include$ sudo locate libusb.h
/usr/include/libusb-1.0/libusb.h
我试图#include <libusb.h>
用#include <libusb-1.0/libusb.h>
(如建议的here和here)替换原来的,这导致了不同的失败:
/rtl-sdr/build$ make
[ 6%] Built target convenience_static
Scanning dependencies of target rtlsdr
[ 9%] Building C object src/CMakeFiles/rtlsdr.dir/librtlsdr.c.o
[ 12%] Linking C shared library librtlsdr.so
[ 28%] Built target rtlsdr
[ 31%] Linking C executable rtl_test
librtlsdr.so.0.6git: undefined reference to `libusb_open'
librtlsdr.so.0.6git: undefined reference to `libusb_release_interface'
librtlsdr.so.0.6git: undefined reference to `libusb_close'
librtlsdr.so.0.6git: undefined reference to `libusb_get_string_descriptor_ascii'
librtlsdr.so.0.6git: undefined reference to `libusb_get_device_list'
librtlsdr.so.0.6git: undefined reference to `libusb_kernel_driver_active'
librtlsdr.so.0.6git: undefined reference to `libusb_alloc_transfer'
librtlsdr.so.0.6git: undefined reference to `libusb_bulk_transfer'
librtlsdr.so.0.6git: undefined reference to `libusb_reset_device'
librtlsdr.so.0.6git: undefined reference to `libusb_handle_events_timeout'
librtlsdr.so.0.6git: undefined reference to `libusb_get_device'
librtlsdr.so.0.6git: undefined reference to `libusb_exit'
librtlsdr.so.0.6git: undefined reference to `libusb_free_transfer'
librtlsdr.so.0.6git: undefined reference to `libusb_init'
librtlsdr.so.0.6git: undefined reference to `libusb_get_device_descriptor'
librtlsdr.so.0.6git: undefined reference to `libusb_free_device_list'
librtlsdr.so.0.6git: undefined reference to `libusb_claim_interface'
librtlsdr.so.0.6git: undefined reference to `libusb_control_transfer'
librtlsdr.so.0.6git: undefined reference to `libusb_submit_transfer'
librtlsdr.so.0.6git: undefined reference to `libusb_dev_mem_free'
librtlsdr.so.0.6git: undefined reference to `libusb_cancel_transfer'
collect2: error: ld returned 1 exit status
src/CMakeFiles/rtl_test.dir/build.make:96: recipe for target 'src/rtl_test' failed
make[2]: *** [src/rtl_test] Error 1
CMakeFiles/Makefile2:138: recipe for target 'src/CMakeFiles/rtl_test.dir/all' failed
make[1]: *** [src/CMakeFiles/rtl_test.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
请注意,此建议似乎与我不知道在哪里找到的 gcc 编译选项/链接--cflags libusb-1.0
或-lusb-1.0
(参见此处和此处make
)相关联(因为我正在使用,但不习惯)。
我还尝试#include <libusb.h>
用(如此处#include <usb.h>
所见)替换原来的,这导致:
/rtl-sdr/src/librtlsdr.c:97:2: error: unknown type name ‘libusb_context’
仅供参考libusb-1.0-0-dev
并且libusb-dev
已经安装(如建议here,我试过了,尽管我想我已经安装了它......):
/usr/include$ sudo apt install libusb-1.0-0-dev
libusb-1.0-0-dev is already the newest version (2:1.0.21-2).
~$ sudo apt install libusb-dev
libusb-dev is already the newest version (2:0.1.12-31).
并且已经安装rtl-sdr
使用apt
:
sudo apt-get install rtl-sdr
rtl-sdr is already the newest version (0.5.3-13).
关于我的系统:Linux version 5.4.0-58-generic gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)。此安装旨在能够将 DVB-T 加密狗与 GNU Radio 一起使用,这需要此rtl-sdr
安装。
编辑: @Tsyvarev 回答后
- 安装
pkg-config
有sudo apt install pkg-config
- 删除了由初始
git clone
、新清理git clone
、新/build
等产生的第一个存储库,然后make
,它起作用了!
删除旧的存储库克隆并重新创建一个干净是必要的,因为即使在安装后/build
尝试make
在旧版本中启动也不起作用。请注意,这意味着不需要对./build
pkg-config
#include <libusb.h>
src/librtlsdr.c
作为旁注,对于那些因为试图为 GNU Radio 安装“RTL-SDR Source”块而最终来到这里的人,我怀疑我的问题实际上是我在安装后没有安装gr-osmosdr
一个sudo apt install gr-osmosdr
简单rtl-sdr
的sudo apt-get install rtl-sdr
.