0

I'm trying to build a Qt project on QtCreator on Windows (already works on Ubuntu). I would like to build it on Debug mode and then on Release mode as I wish to deploy my app to Windows.

When 1st compiling the project, I had the following error C1083: Cannot open include file 'libusb.h' no such file or directory. I solved this error by copying the libusb.h file from E:\Qt\5.11.2\Src\qtwebengine\src\3rdparty\chromium\third_party\libusb\src\libusb into my compiler folder : E:\Qt\5.11.2\msvc2017_64\include.

After cleaning and compiling the project again, I have another error for which I can't find a solution, even though I googled it and tried to change the LIB += -lusb-1.0 line of my .pro file. Here is the error: LNK1104: cannot open fileusb-1.0.lib`

Here is my project file :

QT += quick core
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
    main.cpp \
    readthread.cpp \
    passerelle.cpp

RESOURCES += qml.qrc
QML_IMPORT_PATH =
QML_DESIGNER_IMPORT_PATH =
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADER += \
    readthread.h \
    passerelle.h

LIBS += -lusb-1.0

I call #include <libusb.h> in the readthread.h file.

Would you happen to know how to fix this, and why is the compiler looking for usb-1.0.lib instead of libusb-1.0.lib ?

I already tried copying the libusb-1.0.lib file from the downloaded Latest Windows Binary downloads folder (libusb-1.0.22\MS64\dll\libusb-1.0.lib) but it didn't change anything...

Juliette Marquis
  • 159
  • 1
  • 1
  • 13
  • just use `LIBS += libusb-1.0.lib` – Matthieu Brucher Feb 08 '19 at 11:30
  • I still have the same error :/ – Juliette Marquis Feb 08 '19 at 11:38
  • You have then an error saying cannot open `usb-1.0.lib`? Did you try the full path? – Matthieu Brucher Feb 08 '19 at 11:41
  • Yes, I have the exact same error : `LNK1104: cannot open file `libusb-1.0.lib`. By full path, you mean, write `LIBS += E:\Qt\5.11.2\msvc2017_64\lib\libusb-1.0.lib` ? – Juliette Marquis Feb 08 '19 at 11:44
  • Yes, try this. Then, the issue is the QMake is really not great for these :/ – Matthieu Brucher Feb 08 '19 at 11:45
  • I tried different ways but it didn't work : I still have the same error... What do you mean with QMake is really not great for these and what other solution do I have ? – Juliette Marquis Feb 08 '19 at 12:00
  • QMake is a tool that even people from Qt are considering dropping. Have a look at CMake, which is the almost C++ standard for building C++ apps. – Matthieu Brucher Feb 08 '19 at 12:01
  • 1
    Mmm ok, I'm gonna have a look at CMake then, see if it solves my problem. I'll come back once I've tried a few things with CMake :). But I still don't understand well why it worked really well on Linux with QMake but not on Windows – Juliette Marquis Feb 08 '19 at 12:06
  • ***cannot open fil 'usb-1.0.lib'*** This error can happen for 3 reasons: 1. Your path to the lib file is wrong 2. You are mixing 32 and 64 bit or 3. The .lib file is corrupt – drescherjm Feb 08 '19 at 13:38
  • @drescherjm I checked the path and that I am using 64 bits versions of the files. But I don't know how to know whether the .lib file is corrupt or not :/ – Juliette Marquis Feb 08 '19 at 14:59
  • @MatthieuBrucher I solved it ! Thank you very much. Each time I was trying a new solution, I was cleaning and building the whole project but I forgot to run qmake again... My bad, with `LIBS += E:\Qt\5.11.2\msvc2017_64\lib\libusb-1.0.lib`, it works. Maybe you can post your comment as answer so that I can validate it and have the question SOLVED :) – Juliette Marquis Feb 08 '19 at 16:18

1 Answers1

1

The answer appears in the comments above, but here I write it again: I solved it by using the full path : LIBS+= E:\Qt\5.11.2\msvc2017_64\lib\libusb-1.0.lib. Once the modification has been done, clean, run qmake and build the project.

Juliette Marquis
  • 159
  • 1
  • 1
  • 13