Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved TEMPLATE = app doesn't seem to work correctly with Qt Creator 4.11

    General and Desktop
    executable sharedlib template linux
    2
    8
    658
    Loading More Posts
    • 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.
    • M
      mdresser last edited by

      I'm running Ubuntu 18.04, Qt 5.14, Qt Creator 4.11.

      I have code that was working with Qt 5.9 on Ubuntu 16.04 that I am migrating to the new platform. The applications build without error and run fine from Qt Creator or the terminal but not from the GUI. The executable file properties show it as shared library (application/x-sharedlib) rather than executable (application/x-executable).

      As I understand it, the line TEMPLATE = app near the beginning of the .pro file should take care of this but it doesn't seem to be working as I expect based on the earlier version of Qt Creator.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        What exact Kit are you using ?
        What is the compiler ?

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

        M 3 Replies Last reply Reply Quote 0
        • M
          mdresser @SGaist last edited by

          @SGaist
          I installed from qt-opensource-linux-x64-5.14.1.run

          The only build kit I have set up is Desktop Qt 5.14.1 GCC 64bit (default)

          The compiler is shown as GCC (C++, x86 64bit in /usr/bin)

          mark@mark:/usr/bin$ g++ --version
          g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

          1 Reply Last reply Reply Quote 0
          • M
            mdresser @SGaist last edited by

            @SGaist
            I found this on StackOverflow: https://stackoverflow.com/questions/34519521/why-does-gcc-create-a-shared-object-instead-of-an-executable-binary-according-to
            It looks like it might be related to my problem but I'm not sure how to get Qt Creator to link with the -no-pie switch.

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Wait, there's something strange in what you wrote.

              You wrote that it worked from Qt Creator and from the console but the from the GUI. Can you give more details about that ?

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

              M 1 Reply Last reply Reply Quote 0
              • M
                mdresser @SGaist last edited by

                @SGaist
                Adding this to the .pro file seems to resolve the problem: QMAKE_LFLAGS += -no-pie

                1 Reply Last reply Reply Quote 0
                • M
                  mdresser @SGaist last edited by

                  @SGaist
                  The StackOverflow entry explains it better than I could but essentially, GCC can build a shared library that is executable if it includes main(). Qt Creator is OK with trying to execute it and it works, Terminal will try to do whatever the user tells it and it works. The GUI launcher is apparently smart enough to check the file type before it tries to execute and doesn't want to execute a shared library.
                  Apparently, the default for the version of GCC that I ended up using is to build this kind of file unless you include the -no-pie switch on the linker.

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    Thanks for the summary !

                    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 Reply Quote 0
                    • First post
                      Last post