Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Qt creator use .so in linux
Forum Updated to NodeBB v4.3 + New Features

Qt creator use .so in linux

Scheduled Pinned Locked Moved Language Bindings
11 Posts 3 Posters 7.9k 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.
  • Y Offline
    Y Offline
    yasibeiersi
    wrote on 13 Dec 2011, 10:47 last edited by
    #1

    I want to use qt creator binding the .so generated by matlab in linux.
    It will be great to show me a simple example of how qt using the .so generated by matlab.
    Many thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on 13 Dec 2011, 10:50 last edited by
      #2

      Qt Creator usually uses qmake to build its stuff, so I have to refer you to "the qmake documentation":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#libs.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on 13 Dec 2011, 12:10 last edited by
        #3

        Section "Declaring Other Libraries" of the "qmake Project Files":http://developer.qt.nokia.com/doc/qt-4.7/qmake-project-files.html manual has an example on how to use external libraries in your project.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yasibeiersi
          wrote on 14 Dec 2011, 13:44 last edited by
          #4

          When I try to open a shared library **.so,Qt Creator shows this mistake:
          Fatal error: cannot get path to runtime module.

          [quote author="Volker" date="1323778201"]Section "Declaring Other Libraries" of the "qmake Project Files":http://developer.qt.nokia.com/doc/qt-4.7/qmake-project-files.html manual has an example on how to use external libraries in your project.[/quote]

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on 17 Dec 2011, 00:28 last edited by
            #5

            Where do you "open" a shared library in Creator?

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • Y Offline
              Y Offline
              yasibeiersi
              wrote on 17 Dec 2011, 10:06 last edited by
              #6

              @
              void *handle;
              void (*myfun)(void);
              char *error;

              handle = dlopen ("libadd.so", RTLD_LAZY);
              if (!handle) {
              fprintf (stderr, "%s\n", dlerror());
              }

              dlerror();
              *(void **) (&myfun) = dlsym(handle, "add");

              dlerror();

              (*myfun)();
              dlclose(handle);

              @

              [EDIT: code formatting, Volker]

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on 18 Dec 2011, 00:47 last edited by
                #7

                Ah, you try to open it in your own application and you see a runtime error message in Creator's output tabs, now I understand.

                Hm, seems as if dlopen doesn't know where to search for your .so - you'll have to use your OS' methods for search paths or use an absolute path.

                Did you consider using [[Doc:QLibrary]] to replace dlopen?

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • Y Offline
                  Y Offline
                  yasibeiersi
                  wrote on 18 Dec 2011, 06:19 last edited by
                  #8

                  @
                  typedef int (*MyPrototype)(int,int);
                  MyPrototype myFunction =
                  (MyPrototype) QLibrary::resolve("/home/liu111/123/libadd.so", "add");
                  int aa=myFunction(0,1);
                  @

                  these codes stops:int aa=myFunction(0,1)
                  and Ccreator says :"The program has unexpectedly finished."
                  But it works very well for the .so provided by MATLAB,like libm.so,and I have tested "cos" from libm.so ,and it works very well. The libadd.so is generated by the libadd.m which is written by myself.The method generating .so from .m works perfectly usder win32,maybe the above problem is caused by MATLAB does not coordinate with linux perfectly.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on 18 Dec 2011, 14:06 last edited by
                    #9

                    Please wrap your code in @-tags to get pretty formatting.

                    Is your library made of C-code or of C++? The latter does not work with resolve.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      yasibeiersi
                      wrote on 19 Dec 2011, 00:34 last edited by
                      #10

                      My library is made of Matlba-code . Matlab can generate *.so from *.m .
                      Thank you very much.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on 19 Dec 2011, 12:53 last edited by
                        #11

                        Sorry, I have no idea how matlab creates its libraries; I'm out here. Maybe someone in a matlab forum can be of better help, as it doesn't seem to be a Qt problem, but more one of interfacing matlab libs with C++ code.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0

                        1/11

                        13 Dec 2011, 10:47

                        • Login

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