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. Link all libraries into the executable (actually: make a deploy folder)
Forum Updated to NodeBB v4.3 + New Features

Link all libraries into the executable (actually: make a deploy folder)

Scheduled Pinned Locked Moved General and Desktop
27 Posts 5 Posters 11.1k 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.
  • P Pippin

    @mrjj said:

    http://www.tripleboot.org/?p=138
    Please say you did read it.

    Yes, I did read it.

    But I think I'm failing to understand what you people want me to do. I've tried to follow the link you showed, and it caused problems, which I have submitted and am waiting for solutions. Especially, I would like to know how to find out the hidden .so files that my project needs.

    @mrjj said:

    and then try to deploy on clean linux.
    if it wont start, i would use ldd to see which so it still needs on the clean machine.

    I've already tried that, but shouldn't it first work on this machine before working on others?

    @kshegunov said:

    You need to extract all Qt's binaries and your external dependencies.

    I'm sorry but as a newbie, I do not know how to do that. I am not using Qt Creator at all, I'm doing everything through the terminal. I use qmake, make and run the executable.

    Also, I'm confused that the open GL library is nowhere to be found as I do link libGL.so.1, libglib-2.0.so.0, libglapi.so.0, libxcb-glx.so.0 and libglib-2.0.so.0. I'm looking forward to your next instructions.

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by kshegunov
    #18

    @Pippin

    I'm sorry but as a newbie, I do not know how to do that. I am not using Qt Creator at all, I'm doing everything through the terminal. I use qmake, make and run the executable.

    I mean that you'd package them with your executable. From your ldd called on the application you get:

    /home/lol/Documents/Coding/Union/./libQt5Core.so.5:
            ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
    

    which means, you'll need to have libQt5Core.so to run your application. However libstdc++.so is a system library and you shouldn't copy it along your application. Additionally, each of the *.so's you copy have dependencies of its own that should be met (meaning you have to copy them if needed as well).

    When you start your application the loader (called also the dynamic linker on Linux) will read up the dependencies and start mapping the libraries to memory. Each of the loaded libraries' dependencies will be loaded as well. For this to happen the loader must know where to find the libraries. The singular path, provided a special rpath variable in the ELF header is not present, is a set of system directories (most commonly /lib, /usr/lib). There's a way to tell the loader where your libraries are located when starting your application with the LD_LIBRARY_PATH system variable, although for most cases this is discouraged. This somewhat lengthily describes what is done by the OS, and in fact is Qt-independent, it's just how Linux works.

    Now, back to your original problem. After you copy all the Qt libraries you're using, and their dependencies (the link @mrjj provided is an excellent staring point), and after you make sure all the system libraries are installed on the sytem (like stdc++, libGL and so on) you can start your application. You do that like this:

    >$ LD_LIBRARY_PATH=/path/to/libraries:$LD_LIBRARY_PATH ./executablename 
    

    /path/to/libraries is where the loader should search for the libraries you've copied, and executablename is the name of your program. If all the prerequisites are met (as described above) you should be able to see that your application runs.

    Kind regards.

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    2
    • A Offline
      A Offline
      asanka424
      wrote on last edited by
      #19

      if you have all your so files in same directory as your executable, it will find those libraries. Only things you want to copy is Qt related libaries. Other than files starting with libQt5 you will need

      libicudata
      libicui18n
      libicuuc.so

      Also platforms directory from qt plugings directory. For example
      /opt/Qt/5.5.1/5.5/gcc_64/plugins.

      kshegunovK 1 Reply Last reply
      0
      • A asanka424

        if you have all your so files in same directory as your executable, it will find those libraries. Only things you want to copy is Qt related libaries. Other than files starting with libQt5 you will need

        libicudata
        libicui18n
        libicuuc.so

        Also platforms directory from qt plugings directory. For example
        /opt/Qt/5.5.1/5.5/gcc_64/plugins.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #20

        @asanka424

        if you have all your so files in same directory as your executable, it will find those libraries.

        On Windows, yes, but not on Linux. You have to explicitly point the loader to the current working directory.

        Read and abide by the Qt Code of Conduct

        A 1 Reply Last reply
        0
        • kshegunovK kshegunov

          @asanka424

          if you have all your so files in same directory as your executable, it will find those libraries.

          On Windows, yes, but not on Linux. You have to explicitly point the loader to the current working directory.

          A Offline
          A Offline
          asanka424
          wrote on last edited by
          #21

          @kshegunov I thought . is default added into rpath. Yes that is build chain specific thing and should not consider as a global thing.

          kshegunovK 1 Reply Last reply
          0
          • P Offline
            P Offline
            Pippin
            wrote on last edited by
            #22

            @kshegunov Thanks for taking the time to break it down for me, I appreciate it. So I'll try to sort the .so file list I made earlier:

            These files should be in my project directory:

            platforms/libqxcb.so
            libsfml-system.so.2.3
            libsfml-network.so.2.3
            libQt5Widgets.so.5
            libQt5Gui.so.5
            libQt5Core.so.5
            

            As well as these files (because of the SFML libraries)

            libfreetype.so.6
            libX11.so.6
            libxcb.so.1
            libX11-xcb.so.1
            libxcb-glx.so.0
            libxcb-dri2.so.0
            libxcb-dri3.so.0
            libxcb-present.so.0
            libxcb-sync.so.1
            libGL.so.1
            libpthread.so.0
            

            As well as these files (because of the Qt libraries)

            libicudata.so.55
            libicui18n.so.55
            libicuuc.so.55
            

            And these files should not be included in my project directory:

            libstdc++.so.6
            libm.so.6
            libgcc_s.so.1
            libc.so.6
            librt.so.1
            libgobject-2.0.so.0
            libglib-2.0.so.0
            libgobject-2.0.so.0
            libpng12.so.0
            libharfbuzz.so.0
            libz.so.1
            libpcre16.so.3
            libdl.so.2
            libffi.so.6
            libpcre.so.3
            libgraphite2.so.3
            libexpat.so.1
            libglapi.so.0
            libXext.so.6
            libXdamage.so.1
            libXfixes.so.3
            libxshmfence.so.1
            libXxf86vm.so.1
            libdrm.so.2
            libXau.so.6
            libXdmcp.so.6
            

            Did I get something wrong in any list? Anyway, I tried that and compiled my project successfully. When I run it however, I still get the old openGL message:

            ./my_app: symbol lookup error: /home/lol/Documents/Coding/Union/libQt5Gui.so.5: undefined symbol: glGetString
            

            which I never had before I started to mess with .so files. I'm not sure how to determine which .so file is needed for glGetString.

            1 Reply Last reply
            0
            • A asanka424

              @kshegunov I thought . is default added into rpath. Yes that is build chain specific thing and should not consider as a global thing.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #23

              @asanka424

              is default added into rpath. Yes that is build chain specific thing and should not consider as a global thing.

              Nope, by default rpath is not set.

              @Pippin

              Leave those to the system (don't copy them with your executable):

              • libfreetype - a fonts library
              • libX11* - X11 libraries
              • libxcb* - more X11 libraries
              • libGL - OpenGL library
              • libpthread - thread support

              Copy libQt* (those that you need, and you seem to have done that) and libic* + the platform plugin (I also see it in your project folder).

              I'm not sure how to determine which .so file is needed for glGetString.

              This would be libGL.so, however if it's installed on your system it should be known to the loader. One thing that might be interfering with that would be some binary incompatibility - either a different compiler was used (unlikely to cause a problem) or a very different version of the library. Did you make sure you have libGL installed on your system?

              Kind regards.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Pippin
                wrote on last edited by Pippin
                #24

                Well I googled the issue, I added -lGL -lstdc++ -lc -lm -lglut -lGLU to LIBS in the .pro file but I still get the error. I really don't know what's happening here :S

                libgl1-mesa-dev is already the newest version.
                
                kshegunovK A 2 Replies Last reply
                0
                • P Pippin

                  Well I googled the issue, I added -lGL -lstdc++ -lc -lm -lglut -lGLU to LIBS in the .pro file but I still get the error. I really don't know what's happening here :S

                  libgl1-mesa-dev is already the newest version.
                  
                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #25

                  @Pippin
                  Could you run ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012 on the command line and paste what it returns? Additionally what does ldd libQt5Gui.so when you run it on your deployment folder's library?

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by
                    #26

                    Hi, just a guess, but you could also try changing the order of the -l files, now you have
                    -lGL -lstdc++ -lc -lm -lglut -lGLU
                    try change to
                    -lstdc++ -lc -lm -lglut -lGLU -lGL

                    1 Reply Last reply
                    0
                    • P Pippin

                      Well I googled the issue, I added -lGL -lstdc++ -lc -lm -lglut -lGLU to LIBS in the .pro file but I still get the error. I really don't know what's happening here :S

                      libgl1-mesa-dev is already the newest version.
                      
                      A Offline
                      A Offline
                      asanka424
                      wrote on last edited by
                      #27

                      @Pippin is this a GUI or a command line app?

                      1 Reply Last reply
                      0

                      • Login

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