Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I can't link the libusb library and change UI
Forum Update on Monday, May 27th 2025

I can't link the libusb library and change UI

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrew23
    wrote on last edited by Andrew23
    #1

    I have 2 issues that I think related. I've copied an entire project folder to another location on my computer as a base to start cause I want to add USB communication features. I added in the new project's folder the files of libusb library: libusb-1.0.dll and libusb-1.0.lib. After that I can build and run my application, but if I made any change in my code I get the error

    :-1: error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0
    

    If I overwrite the libusb-1.0.dll and libusb-1.0.lib with the original ones, I can build and run my application again. Before EVERY build I have to copy and overwrite those libusb files!

    But there is more: I can't modify my User Interface. If I add a button, for example, in the Design window of QtCreator, it doesn't appear in the UI.

    Immagine 2021-01-18 190728.png

    Now I'm wonderig if I've imported (copied) the original project in the wrong way. The only thing that I changed after that was the build directory and nothing else.

    Do you have any sugestion?

    I'm working on a 64-bit environment. Following my .pro file (the last part about usblib comes from a external project, not mine)

    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11 qwt
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        audiometerinterface.cpp \
        codecsettingsdialog.cpp \
        eepromsettingsdialog.cpp \
        evokedpotentialinterface.cpp \
        infodevicedialog.cpp \
        logsdialog.cpp \
        main.cpp \
        evometer.cpp \
        terminaldialog.cpp \
        tympanometryinterface.cpp \
        usbconnection.cpp \
        wellcomeinterface.cpp
    
    HEADERS += \
        audiometerinterface.h \
        codecsettingsdialog.h \
        eepromsettingsdialog.h \
        evokedpotentialinterface.h \
        evometer.h \
        infodevicedialog.h \
        logsdialog.h \
        terminaldialog.h \
        tympanometryinterface.h \
        usbconnection.h \
        wellcomeinterface.h
    
    FORMS += \
        audiometerinterface.ui \
        codecsettingsdialog.ui \
        eepromsettingsdialog.ui \
        evokedpotentialinterface.ui \
        evometer.ui \
        infodevicedialog.ui \
        logsdialog.ui \
        terminaldialog.ui \
        tympanometryinterface.ui \
        wellcomeinterface.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    RESOURCES += \
        imgs.qrc
    
    #-------------------------------------------------
    # Add LibUSB library
    #-------------------------------------------------
    #LIBS += -L.\ -llibusb-1.0
    
    #-------------------------------------------------
    # Make sure to add the required libraries or
    # frameoworks for the demo work depending on
    # what OS is being used
    #-------------------------------------------------
    macx: LIBS += -framework CoreFoundation
    win32: LIBS += -lSetupAPI
    
    #-------------------------------------------------
    # Make sure output directory for object file and
    # executable is in the correct subdirectory
    #-------------------------------------------------
    macx {
        DESTDIR = mac
        OBJECTS_DIR = mac
        MOC_DIR = mac
        UI_DIR = mac
        RCC_DIR = mac
    }
    unix: !macx {
        DESTDIR = linux
        OBJECTS_DIR = linux
        MOC_DIR = linux
        UI_DIR = linux
        RCC_DIR = linux
    }
    win32 {
        DESTDIR = windows
        OBJECTS_DIR = windows
        MOC_DIR = windows
        UI_DIR = windows
        RCC_DIR = windows
    }
    
    OTHER_FILES +=
    
    win32: LIBS += -L$$PWD/ -llibusb-1.0
    
    INCLUDEPATH += $$PWD/
    DEPENDPATH += $$PWD/
    
    jsulmJ 1 Reply Last reply
    0
    • A Andrew23

      @jsulm said in I can't link the libusb library and change UI:

      @Andrew23 Is this the same build folder you used before you copied the project?

      The original project's folders are

      .../QtProjects/Test/MyOriginalProject
      .../QtProjects/Test/build-MyOriginalProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

      now my copied project folders are

      .../QtProjects/MyProject/MyNewQtProject
      .../QtProjects/MyProject/build-MyNewQtProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

      When I created the original project the framework choose the build forlder by default. When I copied the project in the new folder I inherited that and I changed it.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #9

      @Andrew23

      Close Qt Creator, delete the .pro.user file and the build folder, then open the project again and rebuild it.

      Qt has to stay free or it will die.

      A 1 Reply Last reply
      1
      • A Andrew23

        I have 2 issues that I think related. I've copied an entire project folder to another location on my computer as a base to start cause I want to add USB communication features. I added in the new project's folder the files of libusb library: libusb-1.0.dll and libusb-1.0.lib. After that I can build and run my application, but if I made any change in my code I get the error

        :-1: error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0
        

        If I overwrite the libusb-1.0.dll and libusb-1.0.lib with the original ones, I can build and run my application again. Before EVERY build I have to copy and overwrite those libusb files!

        But there is more: I can't modify my User Interface. If I add a button, for example, in the Design window of QtCreator, it doesn't appear in the UI.

        Immagine 2021-01-18 190728.png

        Now I'm wonderig if I've imported (copied) the original project in the wrong way. The only thing that I changed after that was the build directory and nothing else.

        Do you have any sugestion?

        I'm working on a 64-bit environment. Following my .pro file (the last part about usblib comes from a external project, not mine)

        QT       += core gui
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        CONFIG += c++11 qwt
        
        # You can make your code fail to compile if it uses deprecated APIs.
        # In order to do so, uncomment the following line.
        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
        
        SOURCES += \
            audiometerinterface.cpp \
            codecsettingsdialog.cpp \
            eepromsettingsdialog.cpp \
            evokedpotentialinterface.cpp \
            infodevicedialog.cpp \
            logsdialog.cpp \
            main.cpp \
            evometer.cpp \
            terminaldialog.cpp \
            tympanometryinterface.cpp \
            usbconnection.cpp \
            wellcomeinterface.cpp
        
        HEADERS += \
            audiometerinterface.h \
            codecsettingsdialog.h \
            eepromsettingsdialog.h \
            evokedpotentialinterface.h \
            evometer.h \
            infodevicedialog.h \
            logsdialog.h \
            terminaldialog.h \
            tympanometryinterface.h \
            usbconnection.h \
            wellcomeinterface.h
        
        FORMS += \
            audiometerinterface.ui \
            codecsettingsdialog.ui \
            eepromsettingsdialog.ui \
            evokedpotentialinterface.ui \
            evometer.ui \
            infodevicedialog.ui \
            logsdialog.ui \
            terminaldialog.ui \
            tympanometryinterface.ui \
            wellcomeinterface.ui
        
        # Default rules for deployment.
        qnx: target.path = /tmp/$${TARGET}/bin
        else: unix:!android: target.path = /opt/$${TARGET}/bin
        !isEmpty(target.path): INSTALLS += target
        
        RESOURCES += \
            imgs.qrc
        
        #-------------------------------------------------
        # Add LibUSB library
        #-------------------------------------------------
        #LIBS += -L.\ -llibusb-1.0
        
        #-------------------------------------------------
        # Make sure to add the required libraries or
        # frameoworks for the demo work depending on
        # what OS is being used
        #-------------------------------------------------
        macx: LIBS += -framework CoreFoundation
        win32: LIBS += -lSetupAPI
        
        #-------------------------------------------------
        # Make sure output directory for object file and
        # executable is in the correct subdirectory
        #-------------------------------------------------
        macx {
            DESTDIR = mac
            OBJECTS_DIR = mac
            MOC_DIR = mac
            UI_DIR = mac
            RCC_DIR = mac
        }
        unix: !macx {
            DESTDIR = linux
            OBJECTS_DIR = linux
            MOC_DIR = linux
            UI_DIR = linux
            RCC_DIR = linux
        }
        win32 {
            DESTDIR = windows
            OBJECTS_DIR = windows
            MOC_DIR = windows
            UI_DIR = windows
            RCC_DIR = windows
        }
        
        OTHER_FILES +=
        
        win32: LIBS += -L$$PWD/ -llibusb-1.0
        
        INCLUDEPATH += $$PWD/
        DEPENDPATH += $$PWD/
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Andrew23 said in I can't link the libusb library and change UI:

        The only thing that I changed after that was the build directory and nothing else

        Where is the build directory? Is it inside project directory?

        A 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Andrew23 said in I can't link the libusb library and change UI:

          The only thing that I changed after that was the build directory and nothing else

          Where is the build directory? Is it inside project directory?

          A Offline
          A Offline
          Andrew23
          wrote on last edited by
          #3

          @jsulm said in I can't link the libusb library and change UI:

          @Andrew23 said in I can't link the libusb library and change UI:

          The only thing that I changed after that was the build directory and nothing else

          Where is the build directory? Is it inside project directory?

          No, it's outside. The project's directory is .../QtProjects/MyProject and the build directory is .../QtProjects/build-MyProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug.

          aha_1980A 1 Reply Last reply
          0
          • A Andrew23

            @jsulm said in I can't link the libusb library and change UI:

            @Andrew23 said in I can't link the libusb library and change UI:

            The only thing that I changed after that was the build directory and nothing else

            Where is the build directory? Is it inside project directory?

            No, it's outside. The project's directory is .../QtProjects/MyProject and the build directory is .../QtProjects/build-MyProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @Andrew23 Make sure you don't have stall Makefile or generated ui_xxx.h files anywhere in your source or build folder.

            You problems sounds to 99% like that.

            Qt has to stay free or it will die.

            A 1 Reply Last reply
            2
            • aha_1980A aha_1980

              @Andrew23 Make sure you don't have stall Makefile or generated ui_xxx.h files anywhere in your source or build folder.

              You problems sounds to 99% like that.

              A Offline
              A Offline
              Andrew23
              wrote on last edited by Andrew23
              #5

              @aha_1980 said in I can't link the libusb library and change UI:

              @Andrew23 Make sure you don't have stall Makefile or generated ui_xxx.h files anywhere in your source or build folder.

              You problems sounds to 99% like that.

              In my source folder ( .../QtProjects/MyProject ) I haven't any Makefile or ui_xxx.h, just my c++ and ui source files. But in the build folder ( .../QtProjects/build-MyProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug ) I have these files

              Immagine 2021-01-19 105027.png

              jsulmJ J.HilkJ 3 Replies Last reply
              0
              • A Andrew23

                @aha_1980 said in I can't link the libusb library and change UI:

                @Andrew23 Make sure you don't have stall Makefile or generated ui_xxx.h files anywhere in your source or build folder.

                You problems sounds to 99% like that.

                In my source folder ( .../QtProjects/MyProject ) I haven't any Makefile or ui_xxx.h, just my c++ and ui source files. But in the build folder ( .../QtProjects/build-MyProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug ) I have these files

                Immagine 2021-01-19 105027.png

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6
                This post is deleted!
                1 Reply Last reply
                0
                • A Andrew23

                  @aha_1980 said in I can't link the libusb library and change UI:

                  @Andrew23 Make sure you don't have stall Makefile or generated ui_xxx.h files anywhere in your source or build folder.

                  You problems sounds to 99% like that.

                  In my source folder ( .../QtProjects/MyProject ) I haven't any Makefile or ui_xxx.h, just my c++ and ui source files. But in the build folder ( .../QtProjects/build-MyProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug ) I have these files

                  Immagine 2021-01-19 105027.png

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  @Andrew23 Is this the same build folder you used before you copied the project?

                  A 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Andrew23 Is this the same build folder you used before you copied the project?

                    A Offline
                    A Offline
                    Andrew23
                    wrote on last edited by
                    #8

                    @jsulm said in I can't link the libusb library and change UI:

                    @Andrew23 Is this the same build folder you used before you copied the project?

                    The original project's folders are

                    .../QtProjects/Test/MyOriginalProject
                    .../QtProjects/Test/build-MyOriginalProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

                    now my copied project folders are

                    .../QtProjects/MyProject/MyNewQtProject
                    .../QtProjects/MyProject/build-MyNewQtProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

                    When I created the original project the framework choose the build forlder by default. When I copied the project in the new folder I inherited that and I changed it.

                    aha_1980A 1 Reply Last reply
                    0
                    • A Andrew23

                      @jsulm said in I can't link the libusb library and change UI:

                      @Andrew23 Is this the same build folder you used before you copied the project?

                      The original project's folders are

                      .../QtProjects/Test/MyOriginalProject
                      .../QtProjects/Test/build-MyOriginalProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

                      now my copied project folders are

                      .../QtProjects/MyProject/MyNewQtProject
                      .../QtProjects/MyProject/build-MyNewQtProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

                      When I created the original project the framework choose the build forlder by default. When I copied the project in the new folder I inherited that and I changed it.

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      @Andrew23

                      Close Qt Creator, delete the .pro.user file and the build folder, then open the project again and rebuild it.

                      Qt has to stay free or it will die.

                      A 1 Reply Last reply
                      1
                      • A Andrew23

                        @aha_1980 said in I can't link the libusb library and change UI:

                        @Andrew23 Make sure you don't have stall Makefile or generated ui_xxx.h files anywhere in your source or build folder.

                        You problems sounds to 99% like that.

                        In my source folder ( .../QtProjects/MyProject ) I haven't any Makefile or ui_xxx.h, just my c++ and ui source files. But in the build folder ( .../QtProjects/build-MyProject-Desktop_Qt_5_15_2_MinGW_64_bit-Debug ) I have these files

                        Immagine 2021-01-19 105027.png

                        J.HilkJ Offline
                        J.HilkJ Offline
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #10

                        @Andrew23 also delete the .qmake.stash file


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        1 Reply Last reply
                        1
                        • aha_1980A aha_1980

                          @Andrew23

                          Close Qt Creator, delete the .pro.user file and the build folder, then open the project again and rebuild it.

                          A Offline
                          A Offline
                          Andrew23
                          wrote on last edited by Andrew23
                          #11

                          @aha_1980 said in I can't link the libusb library and change UI:

                          @Andrew23

                          Close Qt Creator, delete the .pro.user file and the build folder, then open the project again and rebuild it.

                          @J-Hilk said in I can't link the libusb library and change UI:

                          @Andrew23 also delete the .qmake.stash file

                          Thanks guys. I deleted the build folder (where is .qmake.stash) and the .pro.user file in the source directory, and now I can modify my User Interface. But the other strange behaviour about the libusb library remains: if I modify my code I get the error

                          warning: ignoring #pragma warning  [-Wunknown-pragmas]
                          warning: ignoring #pragma warning  [-Wunknown-pragmas]
                          warning: ignoring #pragma warning  [-Wunknown-pragmas]
                          error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0
                          

                          but if I rebuild again the project, it works without errors. So I get the error only the first build after a change. Now, I can live with it, but how I can fix it?

                          aha_1980A 1 Reply Last reply
                          0
                          • A Andrew23

                            @aha_1980 said in I can't link the libusb library and change UI:

                            @Andrew23

                            Close Qt Creator, delete the .pro.user file and the build folder, then open the project again and rebuild it.

                            @J-Hilk said in I can't link the libusb library and change UI:

                            @Andrew23 also delete the .qmake.stash file

                            Thanks guys. I deleted the build folder (where is .qmake.stash) and the .pro.user file in the source directory, and now I can modify my User Interface. But the other strange behaviour about the libusb library remains: if I modify my code I get the error

                            warning: ignoring #pragma warning  [-Wunknown-pragmas]
                            warning: ignoring #pragma warning  [-Wunknown-pragmas]
                            warning: ignoring #pragma warning  [-Wunknown-pragmas]
                            error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0
                            

                            but if I rebuild again the project, it works without errors. So I get the error only the first build after a change. Now, I can live with it, but how I can fix it?

                            aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            @Andrew23 said in I can't link the libusb library and change UI:
                            Hi @Andrew23,

                            I think:

                            warning: ignoring #pragma warning [-Wunknown-pragmas]
                            warning: ignoring #pragma warning [-Wunknown-pragmas]
                            warning: ignoring #pragma warning [-Wunknown-pragmas]

                            and

                            error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0

                            are two different warnings.

                            Have you made sure that the libusb at the mentioned path has a compatible architecture (32 or 64 bit)?

                            Regards

                            Qt has to stay free or it will die.

                            A 1 Reply Last reply
                            0
                            • aha_1980A aha_1980

                              @Andrew23 said in I can't link the libusb library and change UI:
                              Hi @Andrew23,

                              I think:

                              warning: ignoring #pragma warning [-Wunknown-pragmas]
                              warning: ignoring #pragma warning [-Wunknown-pragmas]
                              warning: ignoring #pragma warning [-Wunknown-pragmas]

                              and

                              error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0

                              are two different warnings.

                              Have you made sure that the libusb at the mentioned path has a compatible architecture (32 or 64 bit)?

                              Regards

                              A Offline
                              A Offline
                              Andrew23
                              wrote on last edited by Andrew23
                              #13

                              @aha_1980 said in I can't link the libusb library and change UI:

                              @Andrew23 said in I can't link the libusb library and change UI:
                              Hi @Andrew23,

                              I think:

                              warning: ignoring #pragma warning [-Wunknown-pragmas]
                              warning: ignoring #pragma warning [-Wunknown-pragmas]
                              warning: ignoring #pragma warning [-Wunknown-pragmas]

                              and

                              error: skipping incompatible D:\Documenti\Qt\ProgettoAudiometro\Evometer/libusb-1.0.lib when searching for -llibusb-1.0

                              are two different warnings.

                              Have you made sure that the libusb at the mentioned path has a compatible architecture (32 or 64 bit)?

                              Regards

                              Yes @aha_1980 it was my mistake. I just updated the libusb files downloaded from their website and now all works fine. Thanks a lot.

                              1 Reply Last reply
                              1

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved