command-tab / ch341eeprom

A libusb based programming tool for 24Cxx serial EEPROMs using the WinChipHead CH341A IC
GNU General Public License v3.0
149 stars 58 forks source link

libusb.h file not found #15

Closed SamuelWhittle closed 3 years ago

SamuelWhittle commented 3 years ago

I am having issues compiling this project. I have tried installing the requisites on windows and ubuntu and am getting the same error. How do I get the compiler to be able to locate 'libusb-1.0/libusb.h'? I have tried adding that file to the directory that the ch341eeprom.c file is currently in.

Output from running make: sam@laptop:~/ch341eeprom$ make clang -o ch341eeprom ch341eeprom.c ch341funcs.c -lusb-1.0 ch341eeprom.c:21:10: fatal error: 'libusb-1.0/libusb.h' file not found

include <libusb-1.0/libusb.h>

     ^~~~~~~~~~~~~~~~~~~~~

1 error generated. ch341funcs.c:21:10: fatal error: 'libusb-1.0/libusb.h' file not found

include <libusb-1.0/libusb.h>

     ^~~~~~~~~~~~~~~~~~~~~

1 error generated. make: *** [Makefile:2: default] Error 1

command-tab commented 3 years ago

The angle brackets around the include path indicate that the compiler should look in system-level header include paths (versus using double quotes, which mean that the to-be-included files would be local to the project). Because the compiler can't find them, one of the following is likely true:

Do you see anything libusb related in /usr/include or /usr/local/include?

SamuelWhittle commented 3 years ago

I do not see anything labeled libusb in either of the directories supplied.

Would that indicate the library was not installed correctly?

command-tab commented 3 years ago

I think so... What OS are you on, and with what command did you install libusb?

SamuelWhittle commented 3 years ago

This is my second attempt to compile, the first I attempted on Windows 10, the second I am attempting on WSL 2.0 Ubuntu 20.04 LTS

I have tried installing libusb with brew and with apt.

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

They both return that libusb is installed and up to date.

command-tab commented 3 years ago

I'll spin up an Ubuntu VM and give it a shot and see what I can discover...

SamuelWhittle commented 3 years ago

Here is some info from pkg-config which I think will help:

sam@swhittleLT:/usr/local/include$ pkg-config --list-all | grep "libusb" libusb libusb - USB access library

sam@swhittleLT:/usr/local/include$ pkg-config --libs libusb -lusb

command-tab commented 3 years ago

This worked for me:

git clone https://github.com/command-tab/ch341eeprom.git
apt-get install build-essential
apt-get install clang
apt-get install libusb-1.0-0-dev
make
./ch341eeprom -h
ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC

I think the key was libusb-1.0-0-dev, which includes headers.

SamuelWhittle commented 3 years ago

I had installed all the libusb libraries including the dev library but unfortunately when there were installed the necessary header and .so files were not placed in the correct locations. I manually placed the header and .so files and everything started working.

Thank you for looking into this for me!