How to make libusb library visible to another program?
Since you installed to /usr/local/lib
, pkg-config
will not find your installation unless you set PKG_CONFIG_PATH
appropriately
Try running:
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
in your shell and then re-attempting to build your code
libusb not visible in IDE
Seems like libusb-dev
is missing.
Or
Execute dpkg -L libusb-dev
to list all the files in libusb-dev
package to find out what is appropriate include file name and it's location. Most likely you will end up changing your include to:
#include <usb.h>
Also, it is not enough just to add a header to the program - you need to show what library should be linked to use those symbols that are declared in the header. Add following to your compiler options:
-lusb
Compiling against libusb-dev on Ubuntu
This is what I had to do on Debian. It should be at least similar in Ubuntu.
Install libusb-1.0-0-dev
Instead of:
#include <libusb/libusb.h>
do:
#include <libusb.h>
Compile with:
gcc example.c `pkg-config --libs --cflags libusb-1.0`
Package libusb was not found in the pkg-config search path
Just run:
pkg-config --cflags --libs /usr/local/Cellar/libusb/1.0.20/lib/pkgconfig/libusb-1.0.pc
Problem with Makefile compilation on Ubuntu, -lhidapi-libusb library
What you're trying to do doesn't make sense, and will not work.
libusb and HIDAPI are userspace libraries. They cannot be used within a kernel module.
Adding libusb library to a Qt project in osx
Forming my comment into a proper answer; this is not the correct syntax to use:
LIBS += -L/usr/local/lib -libusb-1.0.a
LIBS += -L<libusb.h>
The proper one would be this:
LIBS += -L/usr/local/lib -lusb-1.0
or
LIBS += -l/full/path/to/libusb-1.0.a
You can drop the second LIBS
line in your initial attempt because you have already specified the path in the former, and putting an "include" statement in there would not be reasonable anyhow. So, this is what you could write for your complete .pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
INCLUDEPATH +=/usr/local/include/libusb-1.0
LIBS += -L/usr/local/lib -lusb-1.0
This is not Qt specific, just generic linkage issue: -lfoo
extends to $(prefix)foo$(suffix)
, where the prefix and suffix are figured out automatically based on the platform. That is, the prefix would be lib
in your case, and suffix would be either .a
or .so
on Unix, probably .dylib
on Mac, etc.
You may wish to look into pkg-config support if it is possible to establish. In that case, you would write something like this what we did in QtSerialPort:
CONFIG += link_pkgconfig
PKGCONFIG += libudev
Yet another option is to add the GUI through the QtCreator IDE or similar IDE that you may be using. There is an option usually in the "Linker" section to add a library. Here are two screenshots from my QtCreator:
Click on the project name on the left in the project source tree navigator, and select Add Library
. Then the first screenshot will come up, and you can select the external option, and then you can see the second.
It is needless to say that you would need to run qmake after these changes to generate the corresponding Makefile on your desired platform.
Compiling a gcc library with 1.0 in name from powershell
Try with (double) quotes around the -lusb-1.0
parameter.
Can't figure out how to link C++ package I want to compile to a library
Ubuntu 18.04 example : Build in /home/name/tmp/
sudo apt install python3-pygments libsnappy-dev libgmp-dev
Downloaded from Ubuntu 20.04 https://packages.ubuntu.com/focal/libdeflate-dev →sudo gdebi libdeflate0_1.5-3_amd64.deb && sudo gdebi libdeflate-dev_1.5-3_amd64.deb
Installed gcc94-c++_9.4.0-9_amd64.deb https://drive.google.com/file/d/1xTbHe8ktjKR2gSmQ0Qcw0WEuMoKR8s_w/view?usp=sharing → sudo gdebi gcc94-c++_9.4.0-9_amd64.deb
git clone https://gitlab.com/german.tischler/libmaus2.git
cd libmaus2/
libtoolize && aclocal && autoheader && automake --add-missing && autoconf
export CC=gcc94 CXX=g++94 && ./configure --prefix=/usr libdir=/usr/lib/x86_64-linux-gnu
make
sudo make install-strip
git clone https://gitlab.com/german.tischler/biobambam2.git
cd biobambam2/
libtoolize && aclocal && autoheader && automake --add-missing && autoconf
export CC=gcc94 CXX=g++94 && ./configure
make
sudo make install-strip
No errors.
Related Topics
Linux Device Driver Unsafe Fxsave/Fxrstor Bug - Any Precedents
How to Rename a Bunch of Files to Eliminate Quote Marks
I Need a Binary Comparison Tool for Win/Linux
Using Curl with Commands in Go
How Event Packet Header Is Getiing in Hci_Send_Req API Implementation
How to Store Data Permanently in /Tmp Directory in Linux
Can an Rpm Spec File "Include" Other Files
How to Get Clock_Gettime(2) Clock in Shell
Sudo/Apt-Get Command Not Found in Git Bash
Reading Memory Pointed by Register with Gdb
Aborting a Blocking Read on Linux
Nasm X86_64 Assembly in 32-Bit Mode: Why Does This Instruction Produce Rip-Relative Addressing Code
Ssh Command Output to Save in a Text File in Shell Script
Compiling and Linking a 32 Bit Application on Debian 64 Bit
Linux Kernel Code in Memory Check with Sha256 Sum