title: fatal error: libusb/libusb.h: No such file or directory librtlsdr install for GNU radio
body: <p>Trying to install <code>rtl-sdr</code> (through <code>git clone git://git.osmocom.org/rtl-sdr.git</code>) thanks to the instructions <a href="http://git%20clone%20git://git.osmocom.org/rtl-sdr.git" rel="nofollow noreferrer">here</a> but can't go further than <code>make</code> in the first sequence of instructions:</p>
  <pre><code>cd rtl-sdr/
  mkdir build
  cd build
  cmake ../
  make
  </code></pre>
  <p>At my first try I got the following error:</p>
  <pre><code>/rtl-sdr/src/librtlsdr.c:30:10: fatal error: libusb.h: No such file or directory
  </code></pre>
  <p>After locating this file:</p>
  <pre><code>/usr/include$ sudo locate libusb.h
  /usr/include/libusb-1.0/libusb.h
  </code></pre>
  <p>I tried to replace the original <code>#include &lt;libusb.h&gt;</code> with <code>#include &lt;libusb-1.0/libusb.h&gt;</code> (as suggested <a href="https://askubuntu.com/questions/629619/how-to-install-libusb">here</a> and <a href="https://stackoverflow.com/questions/49226709/compiling-with-libusb">here</a>), which led to a different failure:</p>
  <pre><code>/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
  </code></pre>
  <p>Note that this suggestion seems to be associated with a gcc compile option / link <code>--cflags libusb-1.0</code> or <code>-lusb-1.0</code> (cf. <a href="https://askubuntu.com/questions/629619/how-to-install-libusb">here</a> and <a href="https://www.raspberrypi.org/forums/viewtopic.php?t=13174" rel="nofollow noreferrer">here</a>) that I don't know where to find (since I'm using <code>make</code>, without being used to it).</p>
  <p>I also tried to replace the original <code>#include &lt;libusb.h&gt;</code> with <code>#include &lt;usb.h&gt;</code> (as seen <a href="https://www.linuxquestions.org/questions/linux-newbie-8/ubuntu-9-10-include-libusb-libusb-h-802880/" rel="nofollow noreferrer">here</a>) which led to:</p>
  <pre><code>/rtl-sdr/src/librtlsdr.c:97:2: error: unknown type name ‘libusb_context’
  </code></pre>
  <p>FYI <code>libusb-1.0-0-dev</code> and <code>libusb-dev</code> are already installed (as suggested <a href="https://www.linuxquestions.org/questions/linux-software-2/installing-rtl-sdr-cmake-error-libusb-1-0-required-to-compile-rtl-sdr-4175674171/" rel="nofollow noreferrer">here</a>, I tried, eventhough I guess I already had it installed...):</p>
  <pre><code>/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).
  </code></pre>
  <p>And already installed <code>rtl-sdr</code> using <code>apt</code>:</p>
  <pre><code>sudo apt-get install rtl-sdr
  rtl-sdr is already the newest version (0.5.3-13).
  </code></pre>
  <p>About my system: <strong>Linux version 5.4.0-58-generic gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)</strong>. This install aims at being able to use a DVB-T dongle with GNU Radio, which requires this <code>rtl-sdr</code> install.</p>
  <p><strong>EDIT:</strong> after @Tsyvarev answer</p>
  <ol>
  <li>installed <code>pkg-config</code> with <code>sudo apt install pkg-config</code></li>
  <li>removed the first repository resulting from the initial <code>git clone</code>, new clean
  <code>git clone</code>, new <code>/build</code> etc and then <code>make</code>, which worked !</li>
  </ol>
  <p>Removing the old repository clone &amp; re-creating a clean <code>/build</code> was necessary, since trying to launch <code>make</code> in the old <code>/build</code> even after the install of <code>pkg-config</code> didn't work. Note that this implies that no change was needed on the <code>#include &lt;libusb.h&gt;</code> code line in <code>src/librtlsdr.c</code>.</p>
  <p>As a side note, for those of you who end up here because they're trying to install the &quot;RTL-SDR Source&quot; block for GNU Radio, I suspect my problem was actually that I hadn't installed <code>gr-osmosdr</code> with <code>sudo apt install gr-osmosdr</code> after installing <code>rtl-sdr</code> with a simple <code>sudo apt-get install rtl-sdr</code>.</p>