0

I'm trying to install libusb (not libusb-win32) on windows 7. I have to link it with Qt 5.0.1. Here are the problems I'm facing

  • In the INSTALL file in the extracted libusb folder, it tells me to cd to the current folder then run ./configure make makeinstall But I got the error

'./configure' is not recognized as a valid command.

Googling this problem usually gives the solution as installing libusb-win32. However, I want to avoid that, as of now.

  • In the libusb library, there were a few MSVC projects, so I built them. That did generated some .lib files. So I proceeded to link them with my Qt project. It recognizes the libusb.h header file but does not link properly. Here is my .pro file

    QT       += core gui widgets
    
    TARGET = Qt_libusb TEMPLATE = app
    
    
    SOURCES += main.cpp\
        qt_libusb.cpp
    
    HEADERS  += qt_libusb.h
    
    FORMS    += qt_libusb.ui
    
    LIBS += -LC:\libusb-1.0.18\Win32\Debug\lib\libusb-1.0
    
    INCLUDEPATH += C:/libusb-1.0.18/libusb DEPENDPATH += C:/libusb-1.0.18/libusb
    

My objective is to link the libusb library with Qt. Please tell me if I haven't 'installed' the library correctly or if I am linking it in a wrong way. thanks

user3079474
  • 1,653
  • 2
  • 24
  • 37
  • 1
    `configure` scripts are for *nix-type operating systems, not Windows. See the instructions in the libusb INSTALL_WIN.txt file. – nobody May 14 '14 at 06:11
  • INSTALL_WIN.txt no such file exists in the extracted library folder. PS I'm using libusb-1.0.18 – user3079474 May 14 '14 at 06:25
  • Why do you want to avoid libusb-win32 – Siyuan Ren May 14 '14 at 07:44
  • I'm trying to port a code into Qt that required CLR support. That code was written for libusb. I don't know how compatible that code will be with libusb-win32 – user3079474 May 14 '14 at 09:10
  • I'd recommend using CMake if libusb already has CMakeLists.txt's – paulm May 14 '14 at 10:22
  • 1
    @paulm I thought of that too, but the package didn't come with CMakeLists.txt file – user3079474 May 15 '14 at 08:49
  • @AndrewMedico the file INSTALL_WIN.txt was present in the previous versions, its just not in this one. It tells us to build the library using the .sln files provided. I had already done that – user3079474 May 15 '14 at 08:52

1 Answers1

2

Your project file does not reference the library. You only provide a path where libraries might be found, but there's no reference to the libusb library itself.

What you're missing is something like

LIBS += -llibusb

You also can't have multiple project file statements on the same line. The below is an error:

TARGET = Qt_libusb TEMPLATE = app

It should look like:

TARGET = Qt_libusb 
TEMPLATE = app
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • do I have to add the following line to my .pro file `LIBS += -llibusb` OR do I have to replace the existing LIBS line with this one only? – user3079474 May 15 '14 at 08:53
  • @user3079474 You need both. The existing line tells the linker where some of the libraries might be found. The new line tells the linker what specific library it needs to link. – Kuba hasn't forgotten Monica May 15 '14 at 11:19
  • I guess it is linking correctly as Qt is able to suggest functions from the libusb library as I type my code. However, it still does not build. I receive errors like this ~\libusb-1.0.18\Win32\Debug\lib\libusb-1.0\core.obj):-1: error: undefined reference to `@__security_check_cookie@4'~ – user3079474 May 15 '14 at 13:58
  • The above error is because I'm using the MinGW version of Qt while the libusb library was compiled using MSVC++. As pointed out by many forums and posts on the internet; MSVC++ and MinGW compiled libraries DO NOT mix well – user3079474 May 16 '14 at 15:36
  • @user3079474 "Qt is able to suggest functions" Qt is an application development framework, it doesn't suggest anything. The suggestions come from Qt Creator, an IDE. Qt Creator and Qt are two separate projects, it just so happens that the former is useful to develop the latter. Creator uses the *source code*, not the binary libraries, so you can get perfectly valid code completion while having a project that won't link. Heck, you can get good code completion without having any implementation of the interface you're trying to use. – Kuba hasn't forgotten Monica May 16 '14 at 18:12