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. Is it possible to link dynamic library /usr/lib64 while making static libraries of Qt
Forum Updated to NodeBB v4.3 + New Features

Is it possible to link dynamic library /usr/lib64 while making static libraries of Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 2.6k Views 2 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on 19 Sept 2016, 15:08 last edited by Qt Enthusiast
    #1

    Why do I have put linker flags for X libraries in my Makefile when integrating static libQtGui and libQtCore

    0
    down vote
    favorite
    When I make static libraries of Qt (libQtCore.a and libQtGui.a) using following steps

    1. cd to path for qt-x11-commercial-src-4.3.3
    2. setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
    3. gmake confclean
    4. ./configure -release -static -largefile -qt3support -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext
    5. gmake
      6 gmake install
      then I have to explicitly put following lines in my makefile to link X libraries in my final executable

    SLIBS += SM ICE Xi Xrender Xfixes Xrandr Xcursor Xinerama freetype Xext z gthread-2.0 glib-2.0 QtGui QtCore fontconfig
    otherwise I get undefined reference for symbols in above X libraries.

    But when I make shared libraries of libQtGui.so and libQtCore.so using following steps

    1. cd to path for qt-x11-commercial-src-4.3.3
    2. setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
    3. gmake confclean
    4. configure -release -shared -largefile -qt3support -qt-libpng -qt-libmng
      -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama
      -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender
      -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext -lz
      -lgthread-2.0
      5 gmake
      6 gmake install
      then I only have to put following lines in my makefile

    SLIBS += QtGui QtCore
    I do not have to put code in my makefile to link X libraries in the final executable

    My question in why do have explicitly link X libraries while integrating static libraries libQtGui.a and libQtCore.a in my final executable

    J K 2 Replies Last reply 20 Sept 2016, 04:44
    0
    • Q Qt Enthusiast
      19 Sept 2016, 15:08

      Why do I have put linker flags for X libraries in my Makefile when integrating static libQtGui and libQtCore

      0
      down vote
      favorite
      When I make static libraries of Qt (libQtCore.a and libQtGui.a) using following steps

      1. cd to path for qt-x11-commercial-src-4.3.3
      2. setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
      3. gmake confclean
      4. ./configure -release -static -largefile -qt3support -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext
      5. gmake
        6 gmake install
        then I have to explicitly put following lines in my makefile to link X libraries in my final executable

      SLIBS += SM ICE Xi Xrender Xfixes Xrandr Xcursor Xinerama freetype Xext z gthread-2.0 glib-2.0 QtGui QtCore fontconfig
      otherwise I get undefined reference for symbols in above X libraries.

      But when I make shared libraries of libQtGui.so and libQtCore.so using following steps

      1. cd to path for qt-x11-commercial-src-4.3.3
      2. setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
      3. gmake confclean
      4. configure -release -shared -largefile -qt3support -qt-libpng -qt-libmng
        -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama
        -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender
        -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext -lz
        -lgthread-2.0
        5 gmake
        6 gmake install
        then I only have to put following lines in my makefile

      SLIBS += QtGui QtCore
      I do not have to put code in my makefile to link X libraries in the final executable

      My question in why do have explicitly link X libraries while integrating static libraries libQtGui.a and libQtCore.a in my final executable

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 20 Sept 2016, 04:44 last edited by
      #2

      @Qt-Enthusiast No, you can't link dynamic libraries to static libraries. Even if this would be possible - what would be the point? In any case your app will depend on those dynamic libraries.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Q Qt Enthusiast
        19 Sept 2016, 15:08

        Why do I have put linker flags for X libraries in my Makefile when integrating static libQtGui and libQtCore

        0
        down vote
        favorite
        When I make static libraries of Qt (libQtCore.a and libQtGui.a) using following steps

        1. cd to path for qt-x11-commercial-src-4.3.3
        2. setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
        3. gmake confclean
        4. ./configure -release -static -largefile -qt3support -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext
        5. gmake
          6 gmake install
          then I have to explicitly put following lines in my makefile to link X libraries in my final executable

        SLIBS += SM ICE Xi Xrender Xfixes Xrandr Xcursor Xinerama freetype Xext z gthread-2.0 glib-2.0 QtGui QtCore fontconfig
        otherwise I get undefined reference for symbols in above X libraries.

        But when I make shared libraries of libQtGui.so and libQtCore.so using following steps

        1. cd to path for qt-x11-commercial-src-4.3.3
        2. setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
        3. gmake confclean
        4. configure -release -shared -largefile -qt3support -qt-libpng -qt-libmng
          -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama
          -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender
          -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext -lz
          -lgthread-2.0
          5 gmake
          6 gmake install
          then I only have to put following lines in my makefile

        SLIBS += QtGui QtCore
        I do not have to put code in my makefile to link X libraries in the final executable

        My question in why do have explicitly link X libraries while integrating static libraries libQtGui.a and libQtCore.a in my final executable

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 21 Sept 2016, 11:42 last edited by
        #3

        @Qt-Enthusiast said in Is it possible to link dynamic library /usr/lib64 while making static libraries of QT:

        Is it possible to link dynamic libraries like -lXi -lXfixes while making static libraries of QT

        Yes.

        @Qt-Enthusiast said in Is it possible to link dynamic library /usr/lib64 while making static libraries of QT:

        and do no link these libraries when making final execuatble

        No!

        @jsulm said in Is it possible to link dynamic library /usr/lib64 while making static libraries of QT:

        No, you can't link dynamic libraries to static libraries.

        Technically you can. Practically, however, it's not so useful, as you pointed out.

        Read and abide by the Qt Code of Conduct

        Q 1 Reply Last reply 23 Sept 2016, 07:00
        1
        • K kshegunov
          21 Sept 2016, 11:42

          @Qt-Enthusiast said in Is it possible to link dynamic library /usr/lib64 while making static libraries of QT:

          Is it possible to link dynamic libraries like -lXi -lXfixes while making static libraries of QT

          Yes.

          @Qt-Enthusiast said in Is it possible to link dynamic library /usr/lib64 while making static libraries of QT:

          and do no link these libraries when making final execuatble

          No!

          @jsulm said in Is it possible to link dynamic library /usr/lib64 while making static libraries of QT:

          No, you can't link dynamic libraries to static libraries.

          Technically you can. Practically, however, it's not so useful, as you pointed out.

          Q Offline
          Q Offline
          Qt Enthusiast
          wrote on 23 Sept 2016, 07:00 last edited by
          #4

          @kshegunov said in Is it possible to link dynamic library /usr/lib64 while making static libraries of Qt:

          Technically you can. Practically, however, it's not so useful, as you pointed out.

          Could you write the sample code how I will link the shared libraries while making static libraries of QT

          configure -release -static -largefile -qt3support -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static
          -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender -fontconfig -lfontconfig
          -tablet -lXi -xkb -glib -lglib-2.0 -lXext -lz -lgthread-2.0

          K 1 Reply Last reply 23 Sept 2016, 12:34
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on 23 Sept 2016, 07:12 last edited by
            #5

            I don't think @kshegunov intention was to give you hope. What you are trying to do is wrong. Even if you do it you'll have duplicate symbols and you will still have to deploy the dynamic libraries. I see no point in what you are trying to do

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on 23 Sept 2016, 11:29 last edited by
              #6

              I have rephrase my question
              t Enthusiast about 3 hours ago @kshegunov
              @kshegunov @jsulm

              I have changed the question , if you can let me know the answet

              1 Reply Last reply
              0
              • Q Qt Enthusiast
                23 Sept 2016, 07:00

                @kshegunov said in Is it possible to link dynamic library /usr/lib64 while making static libraries of Qt:

                Technically you can. Practically, however, it's not so useful, as you pointed out.

                Could you write the sample code how I will link the shared libraries while making static libraries of QT

                configure -release -static -largefile -qt3support -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static
                -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender -fontconfig -lfontconfig
                -tablet -lXi -xkb -glib -lglib-2.0 -lXext -lz -lgthread-2.0

                K Offline
                K Offline
                kshegunov
                Moderators
                wrote on 23 Sept 2016, 12:34 last edited by kshegunov
                #7

                @Qt-Enthusiast
                I still don't get why you want or need this. And as @VRonin correctly deduced from my demeanor, I think it's wrong on so many levels ... but for what's worth here you go:

                configure -L <External Lib Path> -l <External Lib> -I <Additional Include dir>
                

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  Qt Enthusiast
                  wrote on 23 Sept 2016, 12:38 last edited by
                  #8

                  I need this because , I build my executable with this static library on machine linux Red Hat 5 ,8 , the Xi Xfiles so on
                  are picked from /usr./lib64/

                  but on other machine with same configuration linux Red Hat 5 ,8 its says
                  /usr/ld cannot find -Xi .

                  I dont know why

                  K 2 Replies Last reply 23 Sept 2016, 18:29
                  0
                  • Q Qt Enthusiast
                    23 Sept 2016, 12:38

                    I need this because , I build my executable with this static library on machine linux Red Hat 5 ,8 , the Xi Xfiles so on
                    are picked from /usr./lib64/

                    but on other machine with same configuration linux Red Hat 5 ,8 its says
                    /usr/ld cannot find -Xi .

                    I dont know why

                    K Offline
                    K Offline
                    kshegunov
                    Moderators
                    wrote on 23 Sept 2016, 18:29 last edited by kshegunov
                    #9

                    @Qt-Enthusiast said in Is it possible to link dynamic library /usr/lib64 while making static libraries of Qt:

                    but on other machine with same configuration linux Red Hat 5 ,8 its says
                    /usr/ld cannot find -Xi .
                    I dont know why

                    Because you need to link that library to the application if it was used in a static library (that's what @jsulm was referring to, for this type of linkage is being dubious at best). The static library can be linked against dynamic libraries, but will not include, and I can't stress this enough, any symbols from those dynamic libraries. The linkage against the dynamic libraries needs to be done when the final application/shared object is created (when the ELF header is generated). So now you should know why.

                    Since that's somewhat technical matter, my advice yet again is: either link everything statically or link everything dynamically, especially if you're not clear how exactly the linker/loader (co)operate.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    2
                    • Q Qt Enthusiast
                      23 Sept 2016, 12:38

                      I need this because , I build my executable with this static library on machine linux Red Hat 5 ,8 , the Xi Xfiles so on
                      are picked from /usr./lib64/

                      but on other machine with same configuration linux Red Hat 5 ,8 its says
                      /usr/ld cannot find -Xi .

                      I dont know why

                      K Offline
                      K Offline
                      kshegunov
                      Moderators
                      wrote on 23 Sept 2016, 18:42 last edited by
                      #10

                      PS:
                      Read here for how static libraries work.

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0

                      1/10

                      19 Sept 2016, 15:08

                      • Login

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