1

尝试安装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>(如建议的herehere)替换原来的,这导致了不同的失败:

/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 回答后

  1. 安装pkg-configsudo apt install pkg-config
  2. 删除了由初始git clone、新清理 git clone、新/build等产生的第一个存储库,然后make,它起作用了!

删除旧的存储库克隆并重新创建一个干净是必要的,因为即使在安装后/build尝试make在旧版本中启动也不起作用。请注意,这意味着不需要对./buildpkg-config#include <libusb.h>src/librtlsdr.c

作为旁注,对于那些因为试图为 GNU Radio 安装“RTL-SDR Source”块而最终来到这里的人,我怀疑我的问题实际上是我在安装后没有安装gr-osmosdr一个sudo apt install gr-osmosdr简单rtl-sdrsudo apt-get install rtl-sdr.

4

2 回答 2

0

@Tsyvarev 答案(见评论),我把它放在编辑中:在我的问题结束时。我在这里重新发布他的解决方案以关闭问题并将其标记为已解决。

  1. 安装pkg-configsudo apt install pkg-config
  2. 删除了由初始git clone、新清理 git clone、新/build等产生的第一个存储库,然后make,它起作用了!

删除旧的存储库克隆并重新创建一个干净是必要的,因为即使在安装后/build尝试make在旧版本中启动也不起作用。请注意,这意味着不需要对./buildpkg-config#include <libusb.h>src/librtlsdr.c

作为旁注,对于那些因为试图为 GNU Radio 安装“RTL-SDR Source”块而最终来到这里的人,我怀疑我的问题实际上是我在安装后没有安装gr-osmosdr一个sudo apt install gr-osmosdr简单rtl-sdrsudo apt-get install rtl-sdr.

于 2020-12-28T12:18:12.143 回答
0

全程:

sudo apt install pkg-config
sudo apt install libusb-1.0-0
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ..
sudo make install
于 2021-06-07T13:46:51.040 回答