Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How can I integrate an existing Qt project in another Qt project
Forum Updated to NodeBB v4.3 + New Features

How can I integrate an existing Qt project in another Qt project

Scheduled Pinned Locked Moved Solved Mobile and Embedded
26 Posts 4 Posters 5.3k 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.
  • R Robin Hood

    Hello,

    I would like to integrate an existing Qt project in another Qt project. I thought about a solution via libs (libaries).
    The existing Qt project is the QtFirebase Example. When it exists a simple method, for example with libs or other, I'm grateful for comments. Otherwise I know that you can subdivide via subdir, but I would need a step by step statement.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by jsulm
    #2

    @Robin-Hood Start here: http://doc.qt.io/qt-5/sharedlibrary.html
    http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

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

    1 Reply Last reply
    3
    • R Offline
      R Offline
      Robin Hood
      wrote on last edited by
      #3

      Well, I followed the instructions, but it did not really help me. To clarify again, my point is to include push notifications in an existing Qt project. I've done the QtFirebase example and I can get push notifications. Now I would like to integrate this functionality into another project. As mentioned earlier, it would be best if I clicked "Add to Library" within another project and the push notification feature is added.

      Surely there must be a possibility, I am convinced of that. Request for feedback.

      jsulmJ 1 Reply Last reply
      0
      • R Robin Hood

        Well, I followed the instructions, but it did not really help me. To clarify again, my point is to include push notifications in an existing Qt project. I've done the QtFirebase example and I can get push notifications. Now I would like to integrate this functionality into another project. As mentioned earlier, it would be best if I clicked "Add to Library" within another project and the push notification feature is added.

        Surely there must be a possibility, I am convinced of that. Request for feedback.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @Robin-Hood said in How can I integrate an existing Qt project in another Qt project:

        I've done the QtFirebase example and I can get push notifications.

        Then do it like in that example.
        What exactly is the problem?

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

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Robin Hood
          wrote on last edited by
          #5

          Well in the QtFirebase Example project this functionality is included from the beginning. So the whole C ++ files (for qtfirebasemessaging) as well as the platform files (for Android and iOS) are embedded within the whole folder structure. If I want to include these push notifications in a new project, then I do not want to add the individual files and customize my folders and thus all my previous project. I would like to include this feature (push notifications) as a small part in my previous project. It would be best to add this functionality via "Add library". Do you know, what is my problem now?

          jsulmJ 1 Reply Last reply
          0
          • R Robin Hood

            Well in the QtFirebase Example project this functionality is included from the beginning. So the whole C ++ files (for qtfirebasemessaging) as well as the platform files (for Android and iOS) are embedded within the whole folder structure. If I want to include these push notifications in a new project, then I do not want to add the individual files and customize my folders and thus all my previous project. I would like to include this feature (push notifications) as a small part in my previous project. It would be best to add this functionality via "Add library". Do you know, what is my problem now?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Robin-Hood said in How can I integrate an existing Qt project in another Qt project:

            Do you know, what is my problem now?

            No, I don't.
            I already posted links explaining how to create libraries and how to use them.
            You answered that it didn't help you, but you did not tell what exactly is the problem with creating a shared library.

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

            1 Reply Last reply
            1
            • R Offline
              R Offline
              Robin Hood
              wrote on last edited by
              #7

              Soooo ...

              I have some old project (DataSaveModel). In it, I want to include the feature (push notifications), so this app should get push notifications from FCM (Firebase Cloud Messsaging). DataSaveModel is in the subdirsProject (test). I have worked through the tutorial Creating Shared Libraries and Adding Libraries to Projects and unfortunately did not reach my goal. For me it is not easy, what exactly is the problem or why it does not work (compiler shows no error). For this reason I have attached several screenshots to the comment. Please look at the pictures.

              I hope you or anyone else can tell me what's wrong.

              0_1542708752399_Screenshot (48).png

              0_1542708760445_Screenshot (49).png

              0_1542708765784_Screenshot (50).png

              0_1542708771205_Screenshot (51).png

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Robin Hood
                wrote on last edited by
                #8

                On the last picture you can see that I had tested through the console output, if he goes through the command. I do not get console output unfortunately. For this reason, I think that I do not even go into the header file. The acquaintance has already been made. I've also added the library to the project, how to recognize the images, and the folder structure of the project.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Hi,

                  Where do you put your shared library ?
                  Where do you put your application executable ?

                  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
                  0
                  • R Offline
                    R Offline
                    Robin Hood
                    wrote on last edited by
                    #10

                    @SGaist said in How can I integrate an existing Qt project in another Qt project:

                    Where do you put your shared library ?

                    I have created the new static shared libary "mysharedlib" in the subdir "Test". Then I have added the libary to subdir "Test". I thought so with "add libary" I would have put my shared libary (look at third picture).

                    My application executable is in the folder "DataSaveModell" (look at third picture).

                    SUBDIRS += \
                    DataSaveModel \
                    mysharedlib
                    
                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Robin Hood
                      wrote on last edited by
                      #11

                      Or did you mean with "your application exectuable" the .pro-file of the feature "push notifications". This content is in the file "mysharedlib.pro".

                      0_1542790479786_Screenshot (52).png

                      0_1542790488116_Screenshot (53).png

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        A static shared library ?

                        You must also ensure that you build your sub projects in the correct order.

                        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
                        0
                        • R Offline
                          R Offline
                          Robin Hood
                          wrote on last edited by
                          #13

                          @SGaist said in How can I integrate an existing Qt project in another Qt project:

                          A static shared library ?

                          c ++ library - statically linked library

                          Where is my correct ordner??
                          I have send you very many pictures of my project. Can you tell me something useful and no fragments which I can not do anything or think about what you mean by that, please?

                          aha_1980A 1 Reply Last reply
                          0
                          • R Robin Hood

                            @SGaist said in How can I integrate an existing Qt project in another Qt project:

                            A static shared library ?

                            c ++ library - statically linked library

                            Where is my correct ordner??
                            I have send you very many pictures of my project. Can you tell me something useful and no fragments which I can not do anything or think about what you mean by that, please?

                            aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @Robin-Hood said in How can I integrate an existing Qt project in another Qt project:

                            @SGaist said in How can I integrate an existing Qt project in another Qt project:

                            Where is my correct ordner??

                            Usually the library has to be build before the program

                            I have send you very many pictures of my project. Can you tell me something useful and no fragments which I can not do anything or think about what you mean by that, please?

                            Other way round. You gave us lots of fragments. Can't you upload the whole project somewhere?

                            Regards

                            Qt has to stay free or it will die.

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              Robin Hood
                              wrote on last edited by
                              #15

                              ok yes, I upload my whole project here.

                              aha_1980A 1 Reply Last reply
                              0
                              • R Robin Hood

                                ok yes, I upload my whole project here.

                                aha_1980A Offline
                                aha_1980A Offline
                                aha_1980
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                @Robin-Hood where?

                                Qt has to stay free or it will die.

                                1 Reply Last reply
                                0
                                • R Offline
                                  R Offline
                                  Robin Hood
                                  wrote on last edited by
                                  #17

                                  I will now upload a different project than it was in the previous pictures. However, this is based on the same problem and is built exactly the same way. My problem is that my executable file (the project, which I want to include the library. It is located in the folder "QtAndroidJava2Cpp ") does not know the contents of my added library (here: "mylib ") and therefore does not execute. Once you have downloaded the zip file, you will see that I want to output several strings on the console (in Qt-Creator), which are located in "App/mylib/mylib.cpp " and "App/mylib/mylib.h ."
                                  Here you can upload this project under:
                                  zippyshare

                                  aha_1980A 1 Reply Last reply
                                  0
                                  • R Robin Hood

                                    I will now upload a different project than it was in the previous pictures. However, this is based on the same problem and is built exactly the same way. My problem is that my executable file (the project, which I want to include the library. It is located in the folder "QtAndroidJava2Cpp ") does not know the contents of my added library (here: "mylib ") and therefore does not execute. Once you have downloaded the zip file, you will see that I want to output several strings on the console (in Qt-Creator), which are located in "App/mylib/mylib.cpp " and "App/mylib/mylib.h ."
                                    Here you can upload this project under:
                                    zippyshare

                                    aha_1980A Offline
                                    aha_1980A Offline
                                    aha_1980
                                    Lifetime Qt Champion
                                    wrote on last edited by aha_1980
                                    #18

                                    @Robin-Hood

                                    Some words in advance, before I even try to compile the project.

                                    TEMPLATE = subdirs
                                    SUBDIRS +=
                                    QtAndroidJava2Cpp
                                    mylib
                                    CONFIG += ordered

                                    Never use CONFIG+=ORDERED. (And if, you would have to specify the lib first, because the app links against the lib). The correct way is to specify dependencies:

                                    QtAndroidJava2Cpp.depends = mylib

                                    win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/mylib/ -lmylib
                                    else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/mylib/ -lmylibd
                                    else:unix: LIBS += -L$$OUT_PWD/mylib/ -lmylib

                                    INCLUDEPATH += $$PWD/mylib
                                    DEPENDPATH += $$PWD/mylib

                                    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/mylib/libmylib.a
                                    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/mylib/libmylibd.a
                                    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/mylib/mylib.lib
                                    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/mylib/mylibd.lib
                                    else:unix: PRE_TARGETDEPS += $$OUT_PWD/mylib/libmylib.a

                                    All this does not make sense in the pro-file that contains TEMPLATE=SUBDIRS. If you need global configurations, put them in a global.pri and include them in the pro files that needs them.

                                    So far.

                                    Edit:

                                    One more hint: Don't include the .pro.user files when you upload projects. They cannot be shared and just bloat the archive.

                                    That said, I tried to compile your project but it doesn't work as I don't have androidextras (and not even an android compiler).

                                    But I also wonder, why you copied mysharedlib_global.h into the QtAndroidJava2Cpp project? It should be in the shared library project.

                                    Regards

                                    Qt has to stay free or it will die.

                                    1 Reply Last reply
                                    2
                                    • aha_1980A Offline
                                      aha_1980A Offline
                                      aha_1980
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      @Robin-Hood:

                                      Please find a small subdirs example here: https://www64.zippyshare.com/v/XQKzMN1b/file.html

                                      It does what you request, and you should get the point.

                                      Regards

                                      Qt has to stay free or it will die.

                                      1 Reply Last reply
                                      1
                                      • R Offline
                                        R Offline
                                        Robin Hood
                                        wrote on last edited by
                                        #20

                                        Thank you first. I am still very inexperienced in terms of programming with Qt. :/
                                        I have now downloaded the project from you "SubdirsExample". Unfortunately, I can not do it correctly. I get the error messages:

                                        c:/users/robin/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lLib
                                        ..\..\SubdirsExample\App/mainwindow.cpp:13: error: undefined reference to 'Lib::greet()'
                                        collect2.exe: error: ld returned 1 exit status
                                        make[1]: *** [libApp.so] Error 1
                                        make: *** [sub-App-make_first] Error 2
                                        make[1]: Leaving directory `C:/Users/Robin/Documents/build-SubdirsExample-Android_f_r_armeabi_v7a_GCC_4_9_Qt_5_11_1_for_Android_armv7-Debug/App'
                                        09:44:22: Der Prozess "C:\Users\Robin\android-ndk-r17b\prebuilt\windows-x86_64\bin\make.exe" wurde mit dem Rückgabewert 2 beendet.
                                        Fehler beim Erstellen/Deployment des Projekts SubdirsExample (Kit: Android für armeabi-v7a (GCC 4.9, Qt 5.11.1 for Android armv7))
                                        Bei der Ausführung von Schritt "Make"
                                        

                                        0_1542876644668_Screenshot (54).png

                                        I have testet with different devices (with a Android device and with Desktop Qt 5.11.1 32 Bit). Additional I have tried the programm under Windwos and Linux, but the same error message.

                                        I think that the error is in the blue marked line. The compiler tried to read the Lib.lib File, but in order "Lib" I have only:
                                        lib.cpp
                                        lib.h
                                        Lib.pro
                                        lib_global.h

                                        I don´t have a .lib-File.

                                        0_1542876990774_Screenshot (55).png

                                        This is your program. Do you have the same error or do you know, where is the problem in detail?

                                        aha_1980A 1 Reply Last reply
                                        0
                                        • R Robin Hood

                                          Thank you first. I am still very inexperienced in terms of programming with Qt. :/
                                          I have now downloaded the project from you "SubdirsExample". Unfortunately, I can not do it correctly. I get the error messages:

                                          c:/users/robin/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lLib
                                          ..\..\SubdirsExample\App/mainwindow.cpp:13: error: undefined reference to 'Lib::greet()'
                                          collect2.exe: error: ld returned 1 exit status
                                          make[1]: *** [libApp.so] Error 1
                                          make: *** [sub-App-make_first] Error 2
                                          make[1]: Leaving directory `C:/Users/Robin/Documents/build-SubdirsExample-Android_f_r_armeabi_v7a_GCC_4_9_Qt_5_11_1_for_Android_armv7-Debug/App'
                                          09:44:22: Der Prozess "C:\Users\Robin\android-ndk-r17b\prebuilt\windows-x86_64\bin\make.exe" wurde mit dem Rückgabewert 2 beendet.
                                          Fehler beim Erstellen/Deployment des Projekts SubdirsExample (Kit: Android für armeabi-v7a (GCC 4.9, Qt 5.11.1 for Android armv7))
                                          Bei der Ausführung von Schritt "Make"
                                          

                                          0_1542876644668_Screenshot (54).png

                                          I have testet with different devices (with a Android device and with Desktop Qt 5.11.1 32 Bit). Additional I have tried the programm under Windwos and Linux, but the same error message.

                                          I think that the error is in the blue marked line. The compiler tried to read the Lib.lib File, but in order "Lib" I have only:
                                          lib.cpp
                                          lib.h
                                          Lib.pro
                                          lib_global.h

                                          I don´t have a .lib-File.

                                          0_1542876990774_Screenshot (55).png

                                          This is your program. Do you have the same error or do you know, where is the problem in detail?

                                          aha_1980A Offline
                                          aha_1980A Offline
                                          aha_1980
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #21

                                          @Robin-Hood

                                          It seems you already modified my project. It worked perfectly fine for me on Ubuntu, and it should work on Windows too.

                                          Please provide a complete compile log (as text!), preferable from a native compiler. I especially need to see the linker command call.

                                          Qt has to stay free or it will die.

                                          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