简体   繁体   中英

fatal error: libusb/libusb.h: No such file or directory librtlsdr install for GNU radio

Trying to install rtl-sdr (through git clone git://git.osmocom.org/rtl-sdr.git ) thanks to the instructions here but can't go further than make in the first sequence of instructions:

cd rtl-sdr/
mkdir build
cd build
cmake ../
make

At my first try I got the following error:

/rtl-sdr/src/librtlsdr.c:30:10: fatal error: libusb.h: No such file or directory

After locating this file:

/usr/include$ sudo locate libusb.h
/usr/include/libusb-1.0/libusb.h

I tried to replace the original #include <libusb.h> with #include <libusb-1.0/libusb.h> (as suggested here and here ), which led to a different failure:

/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

Note that this suggestion seems to be associated with a gcc compile option / link --cflags libusb-1.0 or -lusb-1.0 (cf. here and here ) that I don't know where to find (since I'm using make , without being used to it).

I also tried to replace the original #include <libusb.h> with #include <usb.h> (as seen here ) which led to:

/rtl-sdr/src/librtlsdr.c:97:2: error: unknown type name ‘libusb_context’

FYI libusb-1.0-0-dev and libusb-dev are already installed (as suggested here , I tried, eventhough I guess I already had it installed...):

/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).

And already installed rtl-sdr using apt :

sudo apt-get install rtl-sdr
rtl-sdr is already the newest version (0.5.3-13).

About my system: Linux version 5.4.0-58-generic gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) . This install aims at being able to use a DVB-T dongle with GNU Radio, which requires this rtl-sdr install.

EDIT: after @Tsyvarev answer

  1. installed pkg-config with sudo apt install pkg-config
  2. removed the first repository resulting from the initial git clone , new clean git clone , new /build etc and then make , which worked !

Removing the old repository clone & re-creating a clean /build was necessary, since trying to launch make in the old /build even after the install of pkg-config didn't work. Note that this implies that no change was needed on the #include <libusb.h> code line in src/librtlsdr.c .

As a side note, for those of you who end up here because they're trying to install the "RTL-SDR Source" block for GNU Radio, I suspect my problem was actually that I hadn't installed gr-osmosdr with sudo apt install gr-osmosdr after installing rtl-sdr with a simple sudo apt-get install rtl-sdr .

whole way:

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

@Tsyvarev answer (see comment), which I put in the EDIT: at the end of my question. I re-post his solution here in order to close the question and mark it as solved.

  1. installed pkg-config with sudo apt install pkg-config
  2. removed the first repository resulting from the initial git clone , new clean git clone , new /build etc and then make , which worked !

Removing the old repository clone & re-creating a clean /build was necessary, since trying to launch make in the old /build even after the install of pkg-config didn't work. Note that this implies that no change was needed on the #include <libusb.h> code line in src/librtlsdr.c .

As a side note, for those of you who end up here because they're trying to install the "RTL-SDR Source" block for GNU Radio, I suspect my problem was actually that I hadn't installed gr-osmosdr with sudo apt install gr-osmosdr after installing rtl-sdr with a simple sudo apt-get install rtl-sdr .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM