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. QApplication object from a shared library
Forum Updated to NodeBB v4.3 + New Features

QApplication object from a shared library

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 1.7k Views 1 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.
  • J Offline
    J Offline
    Jeenus
    wrote on last edited by
    #1

    Hi,

    Operating system : Ubuntu 12.04

    I got crash while trying to create QApplication object. Code I have used is given below.

    int argc = 1;
    char * argv[] = {"QT_APP", NULL};
    QApplication *pqApp;

    pqApp = new QApplication(argc, argv); // Got crash here

    When I tried to debug got backtrace as given below:

    (gdb) bt
    #0 0xa4ec95bb in ?? () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
    #1 0xa4ed4c3b in QString::arg(long long, int, int, QChar) const () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
    #2 0xa503adca in QCoreApplication::applicationFilePath() () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
    #3 0xa503cd67 in QCoreApplication::applicationDirPath() () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
    #4 0xa4e3d96d in ?? () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
    #5 0xa4e3dd39 in QLibraryInfo::platformPluginArguments(QString const&) () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
    #6 0xa53caaab in QGuiApplicationPrivate::createPlatformIntegration() () from /home/user/Qt/5.5/gcc/lib/libQt5Gui.so.5
    #7 0xa8a9265c in ?? ()
    #8 0xabfc9460 in ?? ()
    Backtrace stopped: previous frame inner to this frame (corrupt stack?)

    I am trying to open QT GUI from a '.so' which is loaded by JAVA application.

    JonBJ 1 Reply Last reply
    0
    • J Jeenus

      Hi,

      Operating system : Ubuntu 12.04

      I got crash while trying to create QApplication object. Code I have used is given below.

      int argc = 1;
      char * argv[] = {"QT_APP", NULL};
      QApplication *pqApp;

      pqApp = new QApplication(argc, argv); // Got crash here

      When I tried to debug got backtrace as given below:

      (gdb) bt
      #0 0xa4ec95bb in ?? () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
      #1 0xa4ed4c3b in QString::arg(long long, int, int, QChar) const () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
      #2 0xa503adca in QCoreApplication::applicationFilePath() () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
      #3 0xa503cd67 in QCoreApplication::applicationDirPath() () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
      #4 0xa4e3d96d in ?? () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
      #5 0xa4e3dd39 in QLibraryInfo::platformPluginArguments(QString const&) () from /home/user/Qt/5.5/gcc/lib/libQt5Core.so.5
      #6 0xa53caaab in QGuiApplicationPrivate::createPlatformIntegration() () from /home/user/Qt/5.5/gcc/lib/libQt5Gui.so.5
      #7 0xa8a9265c in ?? ()
      #8 0xabfc9460 in ?? ()
      Backtrace stopped: previous frame inner to this frame (corrupt stack?)

      I am trying to open QT GUI from a '.so' which is loaded by JAVA application.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Jeenus
      What do you mean by "open QT GUI from a '.so' which is loaded by JAVA application"? If you are already inside some application, you cannot create a brand new Qt application inside it, just one application at a time with its own argc/argv from command-line.

      J 1 Reply Last reply
      0
      • JonBJ JonB

        @Jeenus
        What do you mean by "open QT GUI from a '.so' which is loaded by JAVA application"? If you are already inside some application, you cannot create a brand new Qt application inside it, just one application at a time with its own argc/argv from command-line.

        J Offline
        J Offline
        Jeenus
        wrote on last edited by
        #3

        @JonB In my scenario, we are using a third party JAVA application. This application loads a shared library. From this application, we are trying to open a QT GUI. This approach is working in Windows. But in Linux getting crash.

        JAVA application (Third party application) -> Shared library -> Open QT GUI

        mrjjM 1 Reply Last reply
        0
        • J Jeenus

          @JonB In my scenario, we are using a third party JAVA application. This application loads a shared library. From this application, we are trying to open a QT GUI. This approach is working in Windows. But in Linux getting crash.

          JAVA application (Third party application) -> Shared library -> Open QT GUI

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Jeenus
          Hi
          Be aware that on windows platform ( at least)
          the first argument is the full path to exe normally.
          You give it QT_APP which it might not like.
          Not tested what happens if replaced but at least take that into account when
          debugging it. It might need it for locating plugins etc.

          JonBJ 1 Reply Last reply
          2
          • SifuS Offline
            SifuS Offline
            Sifu
            wrote on last edited by
            #5

            You said you are on Ubuntu 12.04. If you are using the default GCC and G++ , it is too old in ubuntu 12.04. You probably need to upgrade gnu compile collection

            PS: better to upgrade ubuntu to 18.04 ( or 16.04 at least )

            J 1 Reply Last reply
            0
            • mrjjM mrjj

              @Jeenus
              Hi
              Be aware that on windows platform ( at least)
              the first argument is the full path to exe normally.
              You give it QT_APP which it might not like.
              Not tested what happens if replaced but at least take that into account when
              debugging it. It might need it for locating plugins etc.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @mrjj

              the first argument is the full path to exe normally.
              You give it QT_APP which it might not like.

              Interesting. argv[0] to a C program can contain any string in any format, even if it usually might be indicating where the program is being run; it certainly should not cause code parsing it to fall over. Yet it does look like QLibraryInfo::platformPluginArguments might be trying to use it to calculate a path in a naughty way from the traceback.

              mrjjM 1 Reply Last reply
              0
              • JonBJ JonB

                @mrjj

                the first argument is the full path to exe normally.
                You give it QT_APP which it might not like.

                Interesting. argv[0] to a C program can contain any string in any format, even if it usually might be indicating where the program is being run; it certainly should not cause code parsing it to fall over. Yet it does look like QLibraryInfo::platformPluginArguments might be trying to use it to calculate a path in a naughty way from the traceback.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @JonB
                Well , maybe its a windows thing ?
                or only when run from creator ?

                This is plain c template.

                alt text

                and run standalone
                alt text

                JonBJ 1 Reply Last reply
                0
                • mrjjM mrjj

                  @JonB
                  Well , maybe its a windows thing ?
                  or only when run from creator ?

                  This is plain c template.

                  alt text

                  and run standalone
                  alt text

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #8

                  @mrjj
                  When C was written, under UNIX the system call to launch an executable was one of :

                  int execl(const char *path, const char *arg, ...  /* (char  *) NULL */);
                  int execv(const char *path, char *const argv[]);
                  

                  The path gave the actual executable to run, but was not available to the executed program. It received only the args or argv. It is customary for the calling program to pass the first arg or argv[0] as the name or path of the program being executed by path, but not compulsory; if you want to go execlp("/bin/ls", "$rubbish&", "-l", NULL) you can, and it will still do /bin/ls -l, the first arg notwithstanding.

                  These arrive at C's main(int argc, char *argv[]). With a minimum of 1 for argc, and argv[0] being non-NULL. Arguments to the program are from the second arg or argv[1] onward. What you do, if anything, with argv[0], in your C program is up to you. But if you rely on it relating to the program being run, it may not.

                  Now, that's C's argc & argv. What Windows/your C runtime may do in the way of setting up argv[0] from ::CreateProcess() or similar is another matter.

                  1 Reply Last reply
                  2
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #9

                    Ok. so it was a windows thing :)
                    I wonder if Qt expects the path or if its something completely different for poster.
                    ps. Good insight.

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Online
                      Christian EhrlicherC Online
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      The only QString::arg() call I see is

                      QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid()));

                      Why this should crash - no idea. Install debug informations for Qt and post the backtrace so we see the line numbers.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      3
                      • SifuS Sifu

                        You said you are on Ubuntu 12.04. If you are using the default GCC and G++ , it is too old in ubuntu 12.04. You probably need to upgrade gnu compile collection

                        PS: better to upgrade ubuntu to 18.04 ( or 16.04 at least )

                        J Offline
                        J Offline
                        Jeenus
                        wrote on last edited by Jeenus
                        #11

                        @Sifu Updated to Ubuntu 16.04 This helped to fix this issue.

                        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