Fatal error libusb h no such file or directory

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

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.

(Applicable to #Ubuntu, #Debian, #Raspbian in my case)
*1st, I followed and apply the steps above of awesome advice and for the most part it got me to the part that I just figured out below. So hopefully the advice aboe + mine equals finally 1 place where all the solutions live and not scattered all over the interwebs.
*Then, made sure I started the steps in the correct directories. So don’t start at /home if you’re supposed to have a specific path per some instructions you already have.
*Test starting at /root, and another test at /yourusername
*if you are making a dir «/src» use the Tilde symbol before the dir name. Damn, I can’t place it in this comment or it does a strike-thru the following words, but the little squiggly symbol under the ESC key if you press Shift). Sounds stupid but fixed one of the errors.
image

Call me crazy, and I’m not a coder, or linux buff, just basic, so I used the help of the GUI.
In my case, getting this to Build and Install and process would fail at multiple stages like Errors above, and at some tar.bz2 extract stages. This is what I did via Terminal and then GUI as I encountered errors:

1 — a few errors at first were simple syntax errors (facepalm complete), such as spelling «libusb» as «lisusb». Again, 🤦 initiated multiple times, but CHECK THIS FIRST.
2 — these are relevant to the above comments, MOST of the issues were DIR issues.
(ie The ones related to the «make» process, a lot of times were because the DIR those files -(ie configure, makefile, the ‘tar.bz2 or tar.gz’ files, etc.,) — were in the wrong directories.
*To fix this, I had to first figure out where they extracted, why they extracted in wrong directories in the first places, then get them into the correct DIRs (/src, /var, /build, /libusb /etc) I did this part via the GUI. as I mentioned.
It was weird cause I was running all the WGET and TAR steps inside the directories some of these online instructions were telling me, like within ‘SRC’ or ‘BUILD’ and so on.

3 — There was a point in the Steps, where you have to ‘cd’ into the DIR ‘libusb vxX.X.X’ and perform commands within it like the MAKE and CONFIGURE process, HOWEVER, you get the errors either:
‘No such Directory’ or another one (can’t and don’t want to remember) with 4 or 5 lines related to Error: Child Directory Something Or Rather and with some numbers, along with the error above in those steps.
*To fix that one, basically it was that the ‘libusb’ file was just that, a FILE. How this happened or why? IDK. The point is I fixed it by old-fashion common sense, ‘MKDIR’. Now that I made a directory, of course it was empty. ##oh, make sure the syntax and version of ‘libusb’ is the version you are installing+downloaded (or ‘wget’ing) when you create the directory manually##
*So basically create the folder you are getting stuck on and errors, then place all the files that are supposed to be in there- I did this using BOTH terminal and GUI.
** Files like «libusb-vX.X» & «libfreekenect» or the distro files. Jus dump them in this new directory you manually made.
**Another error was extracting, «No Such File or DIR» — just use the GUI and double check everything.

4- Missing files or DIRs — Copying and Pasting files from the extracted folder using the GUI into the directories that were either empty, didn’t exist, or already had files in it but were related to where I was getting stuck, is how I fixed a lot of these frustrating errors sometimes.
*Then in each DIR I dropped files in or did some of these things I mentioned, for good measure:

  • I would again do perform a WGET

*sudo apt-get- update (and upgrade) always
*double check everything as you go along ‘ls -a’ and see if things are getting more logical and files are there that are supposed to be (or again, use the GUI)

#Basically I loaded, re-extracted, and packed the sh*t out of everything; didn’t care at this point, just Copy/Pasted Everything starting at the ‘/src’ all the way through ‘/libusb%/build’, even if certain things weren’t supposed to be in there, or had no purpose (as long as it would not trigger adverse effects.)#
The majority of the files I was duplicating and loading every directory with were GENERIC files anyway that came with the distros and releases I was trying to get installed. So I didn’t care, just use common sense (ie You cannot put a «build» directory within itself)

  • If you are copy/pasting using the GUI, Select All the files from the parent DIRs and starts pasting them in the next directory, and so on.
    #I know this might be messy and not the best method, but hey guess what, this is the only thing that worked out off all the advice and sites I found that did nothing ( or a little good but not the ultimate goal).#

Finally started seeing the files that were supposed to be these and solved the ‘no such file’ and ‘makelist’ or no make file errors.

One last thing, since I was Copy/Pasting contents of the DIRS that did have a MAKEFILE and CONFIGURE files, into the DIRs that did not or were acting wonky, launching the config file (GUI) or command (terminal) needs to be done carefully.
For example, make sure if you are taking, say, the CONFIGURE file from a parent directory, that it is still related to the distro or process versions you are trying to install.
GOOD — taking the CONFIGURE file from DIRs in ‘libusb’ and pasting to sub DIRs of linusb.
BAD — taking a CONFIGURE file from DIRs in ‘libusb’ and pasting them into DIRS of ‘freekenct’.

cmake, build, -xjf tar.bz2, and all the steps related to these errors (a few above my comment and my own) all were fixed, and things just started working how they were supposed to after this.

SUMMARY:
-if you are missing a directory, MKDIR and use common sense determining what files are supposed to be in there, and find them and copy them in there.

  • if you are taking files from a parent dir to paste them in a sub dir, make sure you use COPY and not CUT. I know that you’ll have duplicates and a bunch of files in DIRs you won’t need, but who cares, it fixes the issue and whatever it doesn’t need it just won’t use. Space-wise, it doesn’t take up that much.
    -sudo where you get permission errors
    -sudo chmod 777 if you get more permission errors
    -reboot at least once and start all over if you hit a wall
    -use the GUI and extract in either «test» folders or the actual directories (I’m no going to figure out the root cause, so I will be using ‘test’ folders now and doing one thing at a time and reversing that if it didn’t work until I find what does make it work). For now, just use the actual directories- worked for me.
  • and when you get passed your errors and are at steps where you are actually trying to start communicating via usb or testing the cam/device

If somebody can consolidate this into one gold nugget of an article or solution, please do so.
Sorry for long post. I’m thorough, and also come across of posts that people offer solutions but are vague or say things like «try this» out of context and without saying at exactly what steps of before and after what command. Lol.
Hope this helps at least 1 person.

robin1508

Posts: 4
Joined: Thu Jul 26, 2012 11:16 pm

My Pi does not find libusb.h

Hi there,

I wanted to take a look at the libusb library. But I cant even compile a single file including some functions of this library.

This is what I did to install libusb:

Code: Select all

sudo apt-get install libusb-1.0-0-dev

I even downloaded the latest version from http://www.libusb.org/ and made the make installation.

But if I use

the compiler error is:

listdevs.c:24:27: fatal error: libusb/libusb.h: No such file or directory
compilation terminated.

If I use this:

the same error occurs.

or even

Code: Select all

#include </usr/include/libusb-1.0/libusb.h> // this is where the file really is on my Pi!

I get

listdevs.c:(.text+0x28): undefined reference to `libusb_get_device_descriptor’

What did I do wrong?


PaulBuxton

Posts: 57
Joined: Tue Jan 10, 2012 11:38 am

Re: My Pi does not find libusb.h

Thu Aug 02, 2012 9:26 pm

I think that you need to specify the include path so that the compiler knows where to find the header file, and then tell the linker to include the libusb library.
so adding something like

to your gcc compile options should sort you out.

(note the way that linux/gcc handles library names you don’t need to link with -llibusb, just -lusb should do it.

Paul


jdbennet

Posts: 96
Joined: Sun Jul 22, 2012 2:25 pm

Re: My Pi does not find libusb.h

Thu Aug 02, 2012 9:30 pm

You need to link it. This is normal.

I.e. to use ALSA header files, you need to supply -lasound, for pthreads, -lpthread etc….


robin1508

Posts: 4
Joined: Thu Jul 26, 2012 11:16 pm

Re: My Pi does not find libusb.h

Fri Aug 03, 2012 1:35 pm

It still does not work.

This is my code:

Code: Select all

#include <stdio.h>
#include </usr/include/libusb-1.0/libusb.h>

int main(int argc, char **argv) {

        libusb_init(NULL);

        printf("Yeah");
        return 0;
}

if I compile this via

gcc -o driver driver.c -I/usr/include/libusb-1.0/ -lusb

the compiler says «/usr/bin/ld: cannot find -lusb»



User avatar

PeterO

Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: My Pi does not find libusb.h

Fri Aug 03, 2012 5:47 pm

It looks like you have not installed the development version of libusb.
sudo apt-get install libusb-1.0-0.dev
(but you say you have……) :?

In your code
#include <libusb.h>
should work if you use this command to compile
gcc -o driver driver.c -I/usr/include/libusb-1.0/ -lusb

The -I tells the compiler to look in «/usr/include/libusb-1.0» for included files.

HTH
PeterO

Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
«The primary requirement (as we’ve always seen in your examples) is that the code is readable. » Dougie Lawson


ToSa

Posts: 4
Joined: Fri Jul 06, 2012 4:58 pm

Re: My Pi does not find libusb.h

Wed Aug 08, 2012 3:00 pm

I ran into the same issue — and I already had the dev package installed ;)

What I had to do to get it fixed was change the lib from «usb» to «usb-1.0», hence I compiled using the following line:

Code: Select all

gcc -o usbtest usbtest.c -I/usr/include/libusb-1.0/ -lusb-1.0

Cheers,
Tobias


DAFlippers

Posts: 26
Joined: Fri Aug 10, 2012 8:39 am
Location: Berkshire

lleclerc

Posts: 3
Joined: Mon Jun 03, 2013 5:16 pm


sanket123

Posts: 9
Joined: Wed Aug 09, 2017 1:06 pm

Re: My Pi does not find libusb.h

Mon Aug 21, 2017 7:45 am

ToSa wrote: ↑

Wed Aug 08, 2012 3:00 pm


I ran into the same issue — and I already had the dev package installed ;)

What I had to do to get it fixed was change the lib from «usb» to «usb-1.0», hence I compiled using the following line:

Code: Select all

gcc -o usbtest usbtest.c -I/usr/include/libusb-1.0/ -lusb-1.0

Cheers,
Tobias

Hi ,

Is your problem solved ?
I am facing same issue.
can u help me?


User avatar

topguy

Posts: 7312
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: My Pi does not find libusb.h

Wed Aug 23, 2017 6:27 pm

This is a 3 years old thread, its better to create a new one explaining *your* problem with details and error messages.


b.alavi96

Posts: 1
Joined: Sat Dec 07, 2019 1:09 pm

Re: My Pi does not find libusb.h

Sat Dec 07, 2019 1:14 pm

None of this solution works.

I solved this by using this in centos 7 :

for ubuntu and others you can use :

may be required to execute as root by : sudo

The problem is that libusb development build name was libusbx-dev. :D

Hope to be helpful.


Return to “C/C++”

Приветствую!

Ребята, подскажите пожалуйста, уже несколько дней не могу решить проблему с компиляцией программы, которая использует libusb.

Предыстория. Начал разбираться с кросс-компиляцией по этому мануалу: http://telecnatron.com/articles/Cros…nWRT-On-Linux/

Вроде бы всё неплохо, hello world скомпилировалось отлично (опустим танцы с бубном по поводу установки среды для кросс-компиляции, та ещё процедура для меня), на роутере запустилось. Дальше у меня была задача скомпилировать программу dcled (http://www.last-outpost.com/~malakai/dcled/), чтобы попробовать вывести какие-то надписи на подключаемому по USB led-бэджику (в будущем хочу сделать его управляемым по wifi). Скачал исходники программы, распаковал. И тут засада…

Сначало пробовал сделать всё тоже самое, что и с классическим примером:

Код:

# Set up paths and environment for cross compiling for openwrt
export STAGING_DIR=/usr/local/crosscompile/openwrt/staging_dir
export TOOLCHAIN_DIR=$STAGING_DIR/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2
export LDCFLAGS=$TOOLCHAIN_DIR/usr/lib
export LD_LIBRARY_PATH=$TOOLCHAIN_DIR/usr/lib
export PATH=$TOOLCHAIN_DIR/bin:$PATH
mips-openwrt-linux-gcc -g -lm -lusb-1.0 -o dcled dcled.c

На выходе имеем ошибку:

Код:

dcled.c:30:20: fatal error: libusb.h: No such file or directory
 #include <libusb.h>
                    ^
compilation terminated.

Ок… пишут, что можно использовать стандартный make-файл с такими параметрами:

Код:

# Set up paths and environment for cross compiling for openwrt
export STAGING_DIR=/usr/local/crosscompile/openwrt/staging_dir
export TOOLCHAIN_DIR=$STAGING_DIR/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2
export LDCFLAGS=$TOOLCHAIN_DIR/usr/lib
export LD_LIBRARY_PATH=$TOOLCHAIN_DIR/usr/lib
export PATH=$TOOLCHAIN_DIR/bin:$PATH
make CC=mips-openwrt-linux-uclibc-gcc LD=mips-openwrt-linux-uclibc-ld

на выходе:

Код:

mips-openwrt-linux-uclibc-gcc dcled.o -o dcled -g -lm -lusb-1.0
/usr/local/crosscompile/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lusb-1.0
collect2: error: ld returned 1 exit status
make: *** [dcled] Error 1

Перепробовал уже наверное миллион комбинаций и, честно говоря, мозг закипает.

Для справки результат выполнения «locate libusb.h»

Код:

/usr/include/libusb-1.0/libusb.h
/usr/local/crosscompile/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/libusb-1.0.9/ipkg-install/usr/include/libusb-1.0/libusb.h
/usr/local/crosscompile/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/libusb-1.0.9/libusb/libusb.h
/usr/local/crosscompile/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr/include/libusb-1.0/libusb.h

Помогите, а то с ума сойду
Как вариант, может кто-нибудь может скомпилировать мне эту чёртову программу, т.к. я не уверен, что она в итоге у меня заработает и всё может оказаться зря…

ЗАРАНЕЕ СПАСИБО!!!

  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Official Flavours Support
  • Installation & Upgrades
  • [ubuntu] Libusb and how to its package

  1. Question Libusb and how to use its packages

    Hello everyone

    I have a very important question…
    I have installed libusb by using the following command i am not sure if it was right or not and the command was

    sudo apt-get install libusb-dev

    once I have installed (and I am not sure if it has installed or not), I want to know how would I use the library because I write some sample code which uses

    <libusb.h > but when i compile that c++ file using «g++ test_libusb.cpp» that throws the following error,

    «test_libusb.cpp:2:20: fatal error: libusb.h: No such file or directory
    compilation terminated.»


    I am clueless what to do cant find any source on the internet to get to the bottom of this… can anyone please help I am a desperate.. and please treat me as novice on both c/c++ and Ubuntu…

    thanks a lot for you time folks

    hoping for an early response…

    thanks one more time
    Sharif

    Last edited by sh4rif; February 23rd, 2013 at 02:19 PM.


  2. Re: Libusb and how to its package

    code for my cpp file is below

    Code:

    #include <iostream>
    #include <libusb.h>
    
    using namespace std;
    
    int main(){
        //pointer to pointer of device used to retrieve a list of devices
        libusb_device **devs;
        libusb_device_handle *dev_handle; //a device handle
        libusb_context *ctx = NULL; //A LIBUSB session
        int r;// for return values
        ssize_t cnt; //holding number of devices in list
        r = libusb_init(&ctx); // initialize the library for the session we just declared
        
        if(r < 0){
            cout <<"init error "<<r<< endl;
            return 1;
        }
        
        libusb_set_debug(ctx, 3); // set verbosity level to 3, as suggested in the documentation
        cnt = libusb_get_device_list(ctx, &devs); //get the list of devices
        
        if (cnt < 0) {
            cout <<"Get Device Error "<< endl; // there was an error
            return 1;
        }
        
        cout <<cnt<<" Device in list "<< endl;
        dev_handle = libusb_open_device_with_vid_pid(ctx, 5118, 7424) // these are vendor id and product id
        
        if (dev_handle == null){
            cout<<"Cannot open device "<<endl;
        }else{
            cout<<"Device opened"<<endl;
        }
        
        libusb_free_device_list(devs, 1);// free the list unref the devices in it
        
        unsigned char *data = new unsigned char[4];//data to write
        data[0] = 'a';data[1] = 'b';data[2] = 'c';data[3] = 'd';//some dummy values
        
        int actual; //used to find how many bytes were written
        
        if (libusb_kernal_driver_active(dev_handle, 0) == 1){// findout if kernal driver attached
            cout<<"Kernal Driver Active"<<endl;
            if(libus_detach_kernal_driver(dev_handle, 0) == 0 ){    //detach it
                cout<<"Kernal Driver Detached"<<endl;
            }
        }
        
        r = libusb_claim_interface(dev_handle, 0);// claim interface 0 (the first) of devices
        
        if(r < 0){
            cout <<"Cannot claim interface "<<endl;
            return 1;
        }
        
        cout <<"Claimed interface "<<endl;
        
        cout<<"data->"<<data<<"<-"<<endl; // just to see the data we want to write : abcd
        cout<<"Writing data..."<<endl;
        
        r = libusb_bulk_transfer(dev_handle, (2 | LIBUSB_ENDPOINT_OUT), data, 4, &actual, 0);//my device's out endpoint was 2, found withe trial - the device had two endpoints: 2 and 129
        
        if(r == 0 && actual == 4){    // we wrote 4 bytes successfully
            cout<<"Writing successfull"<<endl;
        }else{
            cout<<"write error"<<endl;
        }
        
        r = libusb_release_interface(dev_handle, 0); // release the claimed interface
        
        if (r != 0){
            cout<<"Cannot release interface"<<endl;
            retrun 1;
        }
        cout<<"Released interface"<<endl;
        libusb_close(dev_handle); // close the device we opened
        libusb_exit(ctx); // need to be called to end the
        
        delete[] data// delete the allocated memory for data
        return 0;
        //printf("Hello libusb!");
        //return 0;
    }


  3. Re: Libusb and how to its package

    I think the header file supplied by that package is called usb.h (not libusb.h) — try changing your include instruction to


  4. Re: Libusb and how to its package

    this does not work coz if you check other examples (btw i have copied this example from a website) they are all using libusb


  5. Re: Libusb and how to its package

    Well that file is not part of the libusb-dev package (at least, not on 12.04)

    Code:

    $ apt-file show libusb-dev | grep '.h$'
    libusb-dev: /usr/include/usb.h

    It seems to be in libusb-1.0-0-dev

    Code:

    $ apt-file search -x 'libusb.h$'
    apcupsd-doc: /usr/share/doc/apcupsd/examples/libusb.h
    libusb-1.0-0-dev: /usr/include/libusb-1.0/libusb.h

    Note that because it’s in a subdir of /usr/include you would need to specify it as

    Code:

    #include <libusb-1.0/libusb.h>

    or add a -I include path

    If you want to search on your own system, you can use the apt-cache tool and/ or install apt-file — it’s very useful for tracking down this kind of thing


  6. Re: Libusb and how to its package

    thank you very much «steeldriver» that explanation clears some confusion in my mind but…thanks once again for that

    btw which one is the latest and which one should i use?
    libusb-dev or libusb-1.0-0-dev (considering I am a layman in c/c++ and libusb)
    any resources to learn or understand libusb just wanna run a simple code…

    thanks once again you are a STAR 10 out of 10 for your effort


Bookmarks

Bookmarks


Posting Permissions

Summary: What is ‘usb.h’?

  • Is this a system specific file that should be installed with my OS?
  • Is it a software specific file that should be included with the source code I’m compiling?
  • Is it generically replaceable by download?
  • Can I write this file from scratch?

Expansion:
Very new to Ubuntu. Working my way through installations of my desired software (GNU-RADIO and GNSS-SDR).
While trying to configure a certain piece of hardware (SiGe GN3S Sampler v2 usb device) as an RF-Front End for the software, I received the following errors:

dsradin@dsradin-HP-Pavilion-dv6-Notebook-PC:~/gnss-sdr/drivers/gr-gn3s/build$ make
Scanning dependencies of target gr-gn3s
[ 6%] Building CXX object lib/CMakeFiles/gr-gn3s.dir/gn3s_source_cc.cc.o
In file included from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/fusb.h:26:0,
                 from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/gn3s.h:40,
                 from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/gn3s_source.h:30,
                 from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/gn3s_source_cc.h:35,
                 from /home/dsradin/gnss-sdr/drivers/gr-gn3s/lib/gn3s_source_cc.cc:34:
/home/dsradin/gnss-sdr/drivers/gr-gn3s/include/libusb_types.h:32:17: fatal error: usb.h: No such file or directory
 #include <usb.h>
                 ^
compilation terminated.
make[2]: *** [lib/CMakeFiles/gr-gn3s.dir/gn3s_source_cc.cc.o] Error 1
make[1]: *** [lib/CMakeFiles/gr-gn3s.dir/all] Error 2
make: *** [all] Error 2

I tried looking through the system to find the files with no joy:

dsradin@dsradin-HP-Pavilion-dv6-Notebook-PC:~/gnss-sdr/drivers/gr-gn3s/build$ whereis usb.h
usb:
dsradin@dsradin-HP-Pavilion-dv6-Notebook-PC:~/gnss-sdr/drivers/gr-gn3s/build$ whereis libusb

libusb:

The excerpt from the readme I am following with the instructions say:

  • Build GN3S V2 Custom firmware and driver (OPTIONAL)

Go to GR-GN3S root directory, compile and install the driver:
(read the drivers/gr-gn3s/README for more information)

$ cd gnss-sdr/drivers/gr-gn3s
$ cd build
$ cmake ../
$ make
$ sudo make install
$ sudo ldconfig

Set the environment variable GN3S_DRIVER=1 in order to enable the GN3S_Signal_Source in GNSS-SDR (OPTIONAL)

$ export GN3S_DRIVER=1

In order to gain access to USB ports, gnss-sdr should be used as root.
In addition, the driver requires access to the GN3S firmware binary file.
It should be available in the same path where the application is called.
GNSS-SDR comes with a pre-compiled custom GN3S firmware available at gnss-sdr/firmware/GN3S_v2/bin/gn3s_firmware.ihx.
Please copy this file to the application path. The GNSS-SDR default path is gnss-sdr/install

(in order to disable the GN3S_Signal_Source compilation, you should remove the GN3S_DRIVER variable and build again GNSS-SDR)

I have uninstalled all packages related and re-cloned the GIT repositories that house all the relevant source codes and scoured the internet but without more information about what exactly I’m looking for I’m stuck.

Any suggestions??
Thank you for your help!

Topic: header files not found  (Read 2970 times)

System: Linux Mint 19
Code::Blocks 17.12 -flatpak-
Problem: after a missing libusb I’ve installed the libusb-1.0_dev. The necessary library is here:

/usr/include/libusb-1.0/libusb.h

I’ve added the path for the compiler: /usr/include/libusb-1.0
Compiling fails!
Buildlog:
gcc -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -pg -g -rdynamic -I/usr/include/gtk-3.0 -I/usr/include/gtk-3.0 -I/usr/include/libusb-1.0 -c /home/axel/Projects/Aqualampe_cb/callbacks.c -o obj/Debug/callbacks.o
In file included from /home/axel/Projects/Aqualampe_cb/callbacks.c:30:0:
/home/axel/Projects/Aqualampe_cb/callbacks.h:26:20: fatal error: libusb.h: No such file or directory
 #include <libusb.h>

By typing  #include »  in the editor I got a hugh list of known *.h files. But libusb.h wasn’t in there. Where Code::Blocks got these list or build it? Maybe this is the problem?

Cheers, Panama


Logged


Code::Blocks doesn’t work well/at all if packaged as a flatpak.
Please report this to the person which provided you the flatpak.
We cannot help you at the moment, because supporting flatpaks correctly requires a major redesign of our compiler plugin (at least) and we don’t have the resources to do it at the moment.


Logged

(most of the time I ignore long posts)
[strangers don’t send me private messages, I’ll ignore them; post a topic in the forum, but first read the rules!]


Thank you obfuscated!

I’ll try to install the distro package (it will be the 16.xx version).
I found another issue: the linker call has «-lusb» instead of «-llibusb». So the linking will fail.
Where got CodeBlocks these calls? I couldn’t find any makefile for my project. Could you please explain or is it part of the flatpak?

Cheers, Panama


Logged


I found another issue: the linker call has «-lusb» instead of «-llibusb». So the linking will fail.

-lusb is correct. The linker would automatically prepend the lib when searching for the file.


Logged

(most of the time I ignore long posts)
[strangers don’t send me private messages, I’ll ignore them; post a topic in the forum, but first read the rules!]


Obfuscated: you are totaly right; with CB16.01 -distro package- it is working fine. And the libusb is obviously found.
-Thanks a million-


Logged


Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error libudev h no such file or directory
  • Fatal error libsecp256k1 include secp256k1 h file not found
  • Fatal error libpq fe h нет такого файла или каталога
  • Fatal error libpq fe h no such file or directory
  • Fatal error libguile h no such file or directory

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии