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. Why Qt can't detect library from /usr/lib...
Forum Updated to NodeBB v4.3 + New Features

Why Qt can't detect library from /usr/lib...

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 4 Posters 4.9k Views 3 Watching
  • 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
    Abrar
    wrote on 27 Aug 2018, 06:19 last edited by
    #5

    Can you please tell me how to do so...

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Aug 2018, 06:20 last edited by
      #6

      You already know:

      @Abrar said in Why Qt can't detect library from /usr/lib...:

      LIBS += -L/usr/lib

      That's the correct way.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Abrar
        wrote on 27 Aug 2018, 06:22 last edited by
        #7

        Is there any other way without specifying the lib path?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 27 Aug 2018, 06:26 last edited by
          #8

          What's the problem with that ?

          An alternative for you is to set the LIBRARY_PATH environment variable.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Abrar
            wrote on 27 Aug 2018, 06:33 last edited by
            #9

            Thanks for the alternative...

            S 1 Reply Last reply 27 Aug 2018, 07:01
            0
            • A Abrar
              27 Aug 2018, 06:33

              Thanks for the alternative...

              S Offline
              S Offline
              saber
              wrote on 27 Aug 2018, 07:01 last edited by
              #10

              @Abrar i think this way calling lib is standard as it is included in qt.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Abrar
                wrote on 27 Aug 2018, 07:03 last edited by
                #11

                Can you tell me what is the standard way @saber ....

                S 1 Reply Last reply 27 Aug 2018, 07:07
                0
                • A Abrar
                  27 Aug 2018, 07:03

                  Can you tell me what is the standard way @saber ....

                  S Offline
                  S Offline
                  saber
                  wrote on 27 Aug 2018, 07:07 last edited by
                  #12

                  @Abrar both

                  LIBS += -llibraryname
                  

                  and

                  LIBS += -L/usr/lib -llibraryname
                  

                  i am pretty sure , i know only this tow way. i think @mrjj , @JonB , @VRonin can help you better.

                  A J 2 Replies Last reply 27 Aug 2018, 07:15
                  0
                  • S saber
                    27 Aug 2018, 07:07

                    @Abrar both

                    LIBS += -llibraryname
                    

                    and

                    LIBS += -L/usr/lib -llibraryname
                    

                    i am pretty sure , i know only this tow way. i think @mrjj , @JonB , @VRonin can help you better.

                    A Offline
                    A Offline
                    Abrar
                    wrote on 27 Aug 2018, 07:15 last edited by
                    #13

                    @saber Ok i am waiting for there statement...
                    @mrjj , @JonB , @VRonin

                    1 Reply Last reply
                    0
                    • S saber
                      27 Aug 2018, 07:07

                      @Abrar both

                      LIBS += -llibraryname
                      

                      and

                      LIBS += -L/usr/lib -llibraryname
                      

                      i am pretty sure , i know only this tow way. i think @mrjj , @JonB , @VRonin can help you better.

                      J Offline
                      J Offline
                      JonB
                      wrote on 28 Aug 2018, 10:53 last edited by JonB
                      #14

                      @saber
                      Like @SGaist has said, you change the library search path you must either use -L... or alter the LIBRARY_PATH environment variable. What is the problem with one of these?

                      A 1 Reply Last reply 28 Aug 2018, 11:47
                      0
                      • J JonB
                        28 Aug 2018, 10:53

                        @saber
                        Like @SGaist has said, you change the library search path you must either use -L... or alter the LIBRARY_PATH environment variable. What is the problem with one of these?

                        A Offline
                        A Offline
                        Abrar
                        wrote on 28 Aug 2018, 11:47 last edited by
                        #15

                        @JonB Actually there is no problem. But I just faced another issue that is I created another library and when I include that by -llibraryname that just builds fine...
                        And why is that. As one(my 2nd library) got the path but other(1st library) can't....
                        !!!
                        Please reply....

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 28 Aug 2018, 11:55 last edited by
                          #16

                          Where's that library located ?
                          How are you linking to it ?
                          Do you have any flags set for it that is not set for the first one ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          A 1 Reply Last reply 28 Aug 2018, 14:01
                          0
                          • S SGaist
                            28 Aug 2018, 11:55

                            Where's that library located ?
                            How are you linking to it ?
                            Do you have any flags set for it that is not set for the first one ?

                            A Offline
                            A Offline
                            Abrar
                            wrote on 28 Aug 2018, 14:01 last edited by Abrar
                            #17

                            @SGaist the 2nd library also installs at /usr/lib
                            And I just link it by typing
                            LIBS += -llibraryname
                            Like the 1st library.
                            But didn't add any more thing. And also I test two of them at once.
                            Is there any thing you can tell what is happening?

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 28 Aug 2018, 15:04 last edited by
                              #18

                              As already asked, show your .pro file.

                              From what you wrote, you just added a new library to the list. So the folder was already added earlier.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              1
                              • A Offline
                                A Offline
                                Abrar
                                wrote on 29 Aug 2018, 06:48 last edited by
                                #19
                                #-------------------------------------------------
                                #
                                # Project created by QtCreator 2018-08-20T09:12:54
                                #
                                #-------------------------------------------------
                                
                                QT       += core gui widgets
                                
                                TARGET = help
                                TEMPLATE = app
                                
                                # library for theme
                                unix:!macx: LIBS += -lcprime
                                unix:!macx: LIBS += -lcsys
                                
                                SOURCES += \
                                    main.cpp \
                                    help.cpp
                                
                                HEADERS += \
                                    help.h
                                
                                FORMS += \
                                    help.ui
                                
                                RESOURCES += \
                                    icons.qrc
                                
                                # Disable warnings, enable threading support and c++11 
                                CONFIG += thread silent build_all c++11
                                
                                # Disable Debug on Release
                                # CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
                                
                                # Build location
                                
                                BUILD_PREFIX = $$(CA_BUILD_DIR)
                                
                                isEmpty( BUILD_PREFIX ) {
                                        BUILD_PREFIX = ./build
                                }
                                
                                MOC_DIR       = $$BUILD_PREFIX/moc-qt5
                                OBJECTS_DIR   = $$BUILD_PREFIX/obj-qt5
                                RCC_DIR	      = $$BUILD_PREFIX/qrc-qt5
                                UI_DIR        = $$BUILD_PREFIX/uic-qt5
                                
                                
                                unix {
                                        isEmpty(PREFIX) {
                                                PREFIX = /usr
                                        }
                                        BINDIR = $$PREFIX/bin
                                
                                        target.path = $$BINDIR
                                
                                        desktop.path = $$PREFIX/share/applications/
                                        desktop.files = "Help CoreApps.desktop"
                                
                                        icons.path = $$PREFIX/share/coreapps/icons/
                                        icons.files = icons/Help.svg
                                
                                        INSTALLS += target icons desktop
                                }
                                
                                DEFINES += QT_DEPRECATED_WARNINGS
                                DEFINES += "HAVE_POSIX_OPENPT"
                                

                                This is the .pro file of my application.
                                And my 1st library

                                QT       += widgets core network gui charts concurrent dbus
                                
                                TARGET = csys
                                TEMPLATE = lib
                                
                                # disable all build warnings
                                CONFIG += silent warn_on static
                                
                                # Disable Debug on Release
                                #CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
                                
                                VERSION = 1.0.10
                                DEFINES += LIBCSYS_LIBRARY
                                
                                HEADERS += \
                                    csys/cpu_info.h \
                                    csys/disk_info.h \
                                    csys/memory_info.h \
                                    csys/network_info.h \
                                    csys/process.h \
                                    csys/process_info.h \
                                    csys/system_info.h \
                                    csys/command_util.h \
                                    csys/file_util.h \
                                    csys/format_util.h \
                                    csys/battery.h \
                                    csys/info_manager.h \
                                    csys/upower.h \
                                    csys/udisks2.h \
                                    libcsys_global.h
                                
                                SOURCES += \
                                    csys/cpu_info.cpp \
                                    csys/disk_info.cpp \
                                    csys/memory_info.cpp \
                                    csys/network_info.cpp \
                                    csys/process.cpp \
                                    csys/process_info.cpp \
                                    csys/system_info.cpp \
                                    csys/command_util.cpp \
                                    csys/file_util.cpp \
                                    csys/format_util.cpp \
                                    csys/battery.cpp \
                                    csys/info_manager.cpp \
                                    csys/upower.cpp \
                                    csys/udisks2.cpp
                                
                                MOC_DIR			= ../build/moc
                                OBJECTS_DIR		= ../build/obj
                                RCC_DIR			= ../build/qrc
                                UI_DIR			= ../build/uic
                                
                                unix {
                                        isEmpty(PREFIX) {
                                                PREFIX = /usr
                                        }
                                
                                        INSTALLS	+= target includes
                                        CONFIG		+= create_pc no_install_prl link_pkgconfig
                                        contains(DEFINES, LIB64): target.path = $$INSTALL_PREFIX/lib64
                                        else: target.path = $$INSTALL_PREFIX/lib
                                
                                        target.path			= $$PREFIX/lib/
                                        includes.files	                = libcsys_global.h csys/*.h
                                        includes.path		        = $$PREFIX/include/csys
                                
                                        QMAKE_PKGCONFIG_NAME = libcsys
                                        QMAKE_PKGCONFIG_DESCRIPTION = Library for coreapps
                                        QMAKE_PKGCONFIG_PREFIX  = $$INSTALL_PREFIX
                                        QMAKE_PKGCONFIG_LIBDIR  = $$target.path
                                        QMAKE_PKGCONFIG_INCDIR  = $$includes.path
                                        QMAKE_PKGCONFIG_VERSION = $$VERSION
                                        QMAKE_PKGCONFIG_DESTDIR = pkgconfig
                                }
                                

                                And 2nd Library is

                                QT       += widgets core gui
                                
                                TARGET    = cprime
                                TEMPLATE  = lib
                                
                                # disable all build warnings
                                CONFIG   += silent warn_on thread silent build_all c++11
                                
                                DEFINES  += LIBCPRIME_LIBRARY
                                
                                INCLUDEPATH += ./cprime/
                                DEPENDPATH  += ./cprime/
                                
                                # Disable Debug on Release
                                #CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
                                
                                VERSION  = 1.1.1
                                DEFINES += LIBCPRIME_LIBRARY
                                
                                MOC_DIR			= ../build/moc
                                OBJECTS_DIR		= ../build/obj
                                RCC_DIR			= ../build/qrc
                                UI_DIR			= ../build/uic
                                
                                unix {
                                        isEmpty(PREFIX) {
                                                PREFIX = /usr
                                        }
                                
                                        INSTALLS	 += target includes data themefiles
                                        CONFIG		 += create_pc no_install_prl link_pkgconfig
                                        contains(DEFINES, LIB64): target.path = $$INSTALL_PREFIX/lib64
                                        else: target.path = $$INSTALL_PREFIX/lib
                                
                                        target.path	  = $$PREFIX/lib/
                                
                                        includes.files    = cprime/*.h libcprime_global.h
                                        includes.path     = $$PREFIX/include/cprime/
                                
                                        data.path         = $$PREFIX/share/coreapps/docs
                                        data.files        = docs/Changelog docs/LICENSE docs/To-Do.txt
                                
                                        themefiles.path   = $$PREFIX/share/coreapps/Theme
                                        themefiles.files  = style/*.qss style/*.ini
                                
                                        QMAKE_PKGCONFIG_NAME        = libcprime
                                        QMAKE_PKGCONFIG_DESCRIPTION = Library for coreapps
                                        QMAKE_PKGCONFIG_PREFIX      = $$INSTALL_PREFIX
                                        QMAKE_PKGCONFIG_LIBDIR      = $$target.path
                                        QMAKE_PKGCONFIG_INCDIR      = $$includes.path
                                        QMAKE_PKGCONFIG_VERSION     = $$VERSION
                                        QMAKE_PKGCONFIG_DESTDIR     = pkgconfig
                                }
                                
                                HEADERS += \
                                    cprime/globalfunctions.h \
                                    cprime/utilities.h \
                                    cprime/settingsmanage.h \
                                    cprime/bookmarkmanage.h \
                                    cprime/bookmarkdialog.h \
                                    libcprime_global.h \
                                
                                SOURCES += \
                                    cprime/globalfunctions.cpp \
                                    cprime/utilities.cpp \
                                    cprime/settingsmanage.cpp \
                                    cprime/bookmarkmanage.cpp \
                                    cprime/bookmarkdialog.cpp
                                    
                                FORMS += \
                                    cprime/bookmarkdialog.ui
                                
                                S 1 Reply Last reply 30 Aug 2018, 02:35
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 29 Aug 2018, 21:15 last edited by
                                  #20

                                  Did you check whether you have these libraires in multiple places on your system ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • A Abrar
                                    29 Aug 2018, 06:48
                                    #-------------------------------------------------
                                    #
                                    # Project created by QtCreator 2018-08-20T09:12:54
                                    #
                                    #-------------------------------------------------
                                    
                                    QT       += core gui widgets
                                    
                                    TARGET = help
                                    TEMPLATE = app
                                    
                                    # library for theme
                                    unix:!macx: LIBS += -lcprime
                                    unix:!macx: LIBS += -lcsys
                                    
                                    SOURCES += \
                                        main.cpp \
                                        help.cpp
                                    
                                    HEADERS += \
                                        help.h
                                    
                                    FORMS += \
                                        help.ui
                                    
                                    RESOURCES += \
                                        icons.qrc
                                    
                                    # Disable warnings, enable threading support and c++11 
                                    CONFIG += thread silent build_all c++11
                                    
                                    # Disable Debug on Release
                                    # CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
                                    
                                    # Build location
                                    
                                    BUILD_PREFIX = $$(CA_BUILD_DIR)
                                    
                                    isEmpty( BUILD_PREFIX ) {
                                            BUILD_PREFIX = ./build
                                    }
                                    
                                    MOC_DIR       = $$BUILD_PREFIX/moc-qt5
                                    OBJECTS_DIR   = $$BUILD_PREFIX/obj-qt5
                                    RCC_DIR	      = $$BUILD_PREFIX/qrc-qt5
                                    UI_DIR        = $$BUILD_PREFIX/uic-qt5
                                    
                                    
                                    unix {
                                            isEmpty(PREFIX) {
                                                    PREFIX = /usr
                                            }
                                            BINDIR = $$PREFIX/bin
                                    
                                            target.path = $$BINDIR
                                    
                                            desktop.path = $$PREFIX/share/applications/
                                            desktop.files = "Help CoreApps.desktop"
                                    
                                            icons.path = $$PREFIX/share/coreapps/icons/
                                            icons.files = icons/Help.svg
                                    
                                            INSTALLS += target icons desktop
                                    }
                                    
                                    DEFINES += QT_DEPRECATED_WARNINGS
                                    DEFINES += "HAVE_POSIX_OPENPT"
                                    

                                    This is the .pro file of my application.
                                    And my 1st library

                                    QT       += widgets core network gui charts concurrent dbus
                                    
                                    TARGET = csys
                                    TEMPLATE = lib
                                    
                                    # disable all build warnings
                                    CONFIG += silent warn_on static
                                    
                                    # Disable Debug on Release
                                    #CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
                                    
                                    VERSION = 1.0.10
                                    DEFINES += LIBCSYS_LIBRARY
                                    
                                    HEADERS += \
                                        csys/cpu_info.h \
                                        csys/disk_info.h \
                                        csys/memory_info.h \
                                        csys/network_info.h \
                                        csys/process.h \
                                        csys/process_info.h \
                                        csys/system_info.h \
                                        csys/command_util.h \
                                        csys/file_util.h \
                                        csys/format_util.h \
                                        csys/battery.h \
                                        csys/info_manager.h \
                                        csys/upower.h \
                                        csys/udisks2.h \
                                        libcsys_global.h
                                    
                                    SOURCES += \
                                        csys/cpu_info.cpp \
                                        csys/disk_info.cpp \
                                        csys/memory_info.cpp \
                                        csys/network_info.cpp \
                                        csys/process.cpp \
                                        csys/process_info.cpp \
                                        csys/system_info.cpp \
                                        csys/command_util.cpp \
                                        csys/file_util.cpp \
                                        csys/format_util.cpp \
                                        csys/battery.cpp \
                                        csys/info_manager.cpp \
                                        csys/upower.cpp \
                                        csys/udisks2.cpp
                                    
                                    MOC_DIR			= ../build/moc
                                    OBJECTS_DIR		= ../build/obj
                                    RCC_DIR			= ../build/qrc
                                    UI_DIR			= ../build/uic
                                    
                                    unix {
                                            isEmpty(PREFIX) {
                                                    PREFIX = /usr
                                            }
                                    
                                            INSTALLS	+= target includes
                                            CONFIG		+= create_pc no_install_prl link_pkgconfig
                                            contains(DEFINES, LIB64): target.path = $$INSTALL_PREFIX/lib64
                                            else: target.path = $$INSTALL_PREFIX/lib
                                    
                                            target.path			= $$PREFIX/lib/
                                            includes.files	                = libcsys_global.h csys/*.h
                                            includes.path		        = $$PREFIX/include/csys
                                    
                                            QMAKE_PKGCONFIG_NAME = libcsys
                                            QMAKE_PKGCONFIG_DESCRIPTION = Library for coreapps
                                            QMAKE_PKGCONFIG_PREFIX  = $$INSTALL_PREFIX
                                            QMAKE_PKGCONFIG_LIBDIR  = $$target.path
                                            QMAKE_PKGCONFIG_INCDIR  = $$includes.path
                                            QMAKE_PKGCONFIG_VERSION = $$VERSION
                                            QMAKE_PKGCONFIG_DESTDIR = pkgconfig
                                    }
                                    

                                    And 2nd Library is

                                    QT       += widgets core gui
                                    
                                    TARGET    = cprime
                                    TEMPLATE  = lib
                                    
                                    # disable all build warnings
                                    CONFIG   += silent warn_on thread silent build_all c++11
                                    
                                    DEFINES  += LIBCPRIME_LIBRARY
                                    
                                    INCLUDEPATH += ./cprime/
                                    DEPENDPATH  += ./cprime/
                                    
                                    # Disable Debug on Release
                                    #CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
                                    
                                    VERSION  = 1.1.1
                                    DEFINES += LIBCPRIME_LIBRARY
                                    
                                    MOC_DIR			= ../build/moc
                                    OBJECTS_DIR		= ../build/obj
                                    RCC_DIR			= ../build/qrc
                                    UI_DIR			= ../build/uic
                                    
                                    unix {
                                            isEmpty(PREFIX) {
                                                    PREFIX = /usr
                                            }
                                    
                                            INSTALLS	 += target includes data themefiles
                                            CONFIG		 += create_pc no_install_prl link_pkgconfig
                                            contains(DEFINES, LIB64): target.path = $$INSTALL_PREFIX/lib64
                                            else: target.path = $$INSTALL_PREFIX/lib
                                    
                                            target.path	  = $$PREFIX/lib/
                                    
                                            includes.files    = cprime/*.h libcprime_global.h
                                            includes.path     = $$PREFIX/include/cprime/
                                    
                                            data.path         = $$PREFIX/share/coreapps/docs
                                            data.files        = docs/Changelog docs/LICENSE docs/To-Do.txt
                                    
                                            themefiles.path   = $$PREFIX/share/coreapps/Theme
                                            themefiles.files  = style/*.qss style/*.ini
                                    
                                            QMAKE_PKGCONFIG_NAME        = libcprime
                                            QMAKE_PKGCONFIG_DESCRIPTION = Library for coreapps
                                            QMAKE_PKGCONFIG_PREFIX      = $$INSTALL_PREFIX
                                            QMAKE_PKGCONFIG_LIBDIR      = $$target.path
                                            QMAKE_PKGCONFIG_INCDIR      = $$includes.path
                                            QMAKE_PKGCONFIG_VERSION     = $$VERSION
                                            QMAKE_PKGCONFIG_DESTDIR     = pkgconfig
                                    }
                                    
                                    HEADERS += \
                                        cprime/globalfunctions.h \
                                        cprime/utilities.h \
                                        cprime/settingsmanage.h \
                                        cprime/bookmarkmanage.h \
                                        cprime/bookmarkdialog.h \
                                        libcprime_global.h \
                                    
                                    SOURCES += \
                                        cprime/globalfunctions.cpp \
                                        cprime/utilities.cpp \
                                        cprime/settingsmanage.cpp \
                                        cprime/bookmarkmanage.cpp \
                                        cprime/bookmarkdialog.cpp
                                        
                                    FORMS += \
                                        cprime/bookmarkdialog.ui
                                    
                                    S Offline
                                    S Offline
                                    saber
                                    wrote on 30 Aug 2018, 02:35 last edited by
                                    #21

                                    @Abrar i think you should check if it is installed earlier in other places by you while you are testing.

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      Abrar
                                      wrote on 30 Aug 2018, 04:35 last edited by
                                      #22

                                      That's not installed anywhere else. But the thing is, i found this problem on xubuntu 18.04 at Qt 5.9. But i tried this on Ubuntu 18.04 at Qt 5.9 and it works without typing
                                      -L/usr/lib
                                      i think i have to use -L/usr/lib for me...
                                      And i found my solution. Like
                                      LIBS += -L/usr/lib -llibraryname
                                      Thanks all of you...

                                      1 Reply Last reply
                                      0

                                      14/22

                                      28 Aug 2018, 10:53

                                      • Login

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