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. Use existing windows project to create a dynamic library for iOS and Android?
Forum Updated to NodeBB v4.3 + New Features

Use existing windows project to create a dynamic library for iOS and Android?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
9 Posts 2 Posters 849 Views 2 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.
  • T Offline
    T Offline
    Taytoo
    wrote on 4 Oct 2022, 14:55 last edited by
    #1

    I've created a project in Visual Studio (using Qt tools) on Windows. In windows, the 2 projects statically compile to form a single executable (one is dependent on the other).

    Now I need to use 1 of the projects (containing business logic but No UI) and create dynamic libraries for iOS and Android, so they can be used by apps. I'm not sure how to create a library project that I can configure to build iOS and Android library (.so) without messing up existing VS project?

    If I create a "Qt Class Library" project in Visual Studio and add code to export methods I want, would that be good enough? Then I can do all the development on Windows and just build iOS library on mac? AFAIK, I can build android library on Windows but the library would need to dynamically link with Qt framework?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Oct 2022, 16:32 last edited by
      #2

      Hi,

      I currently don't know how that could be done from a VS perspective.

      From a qmake perspective, you would create SUBDIRS based project were you have one sub-project to build your library and two others to build your applications using that library. You can achieve the same with cmake which I would recommend since it became the default build system for Qt 6 but have a bit less experience with.

      I would recommend you do it this way even for your desktop project, you would have the benefit of having a library (static or shared) for all your platforms and it would just be a switch to change build types rather than having to pretty different projects that would serve the same purpose.

      The other advantage of having your business logic in a library re-used by several applications is that you can more easily test it.

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

      T 1 Reply Last reply 4 Oct 2022, 17:35
      0
      • S SGaist
        4 Oct 2022, 16:32

        Hi,

        I currently don't know how that could be done from a VS perspective.

        From a qmake perspective, you would create SUBDIRS based project were you have one sub-project to build your library and two others to build your applications using that library. You can achieve the same with cmake which I would recommend since it became the default build system for Qt 6 but have a bit less experience with.

        I would recommend you do it this way even for your desktop project, you would have the benefit of having a library (static or shared) for all your platforms and it would just be a switch to change build types rather than having to pretty different projects that would serve the same purpose.

        The other advantage of having your business logic in a library re-used by several applications is that you can more easily test it.

        T Offline
        T Offline
        Taytoo
        wrote on 4 Oct 2022, 17:35 last edited by
        #3

        Just to clarify the iOS/Android apps will be built using Flutter, so the only thing I need to do in my existing project is create a library. Since I've been using VS uptil now, I would prefer using it to manage the project.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Oct 2022, 18:28 last edited by
          #4

          Using cmake does not preclude you from using VS. It provides you with a platform neutral project that you can reuse for Windows, Androïd and other.

          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
          • T Offline
            T Offline
            Taytoo
            wrote on 5 Oct 2022, 21:49 last edited by
            #5

            I'm new to manually compiling code, only did it during school days before :) Is it easier to work with qmake or cmake, any benefit to moving to cmake for Qt5? Since I already have my project setup in VS, I just export .pro and .pri files and the files seems to have all the info needed. On the other hand, for cmake: https://doc.qt.io/qt-5/cmake-get-started.html it looks like I would have to manually create these files?

            What if I keep working within VS, and whenever I need to do android/iOS builds (not much) I just export .pro/.pri files and build using qmake?

            Assuming 3 projects, A = shared lib, B = win32 exe, C = new dynamic library for android/iOS, all of them in same directory i.e. not nested. How would I need to setup .pro file for C to only use A, and create dynamic library for Android? Also, on iOS create dynamic library for that platform?

            Too many questions, but I'm completely new to these iOS and android platforms so getting confused.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 6 Oct 2022, 19:42 last edited by
              #6

              Why would you need C in the first place since A is already a library ?

              You can't have all three projects in one .pro file.

              Subdirs is the correct solution.

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

              T 1 Reply Last reply 10 Oct 2022, 14:23
              1
              • S SGaist
                6 Oct 2022, 19:42

                Why would you need C in the first place since A is already a library ?

                You can't have all three projects in one .pro file.

                Subdirs is the correct solution.

                T Offline
                T Offline
                Taytoo
                wrote on 10 Oct 2022, 14:23 last edited by
                #7

                @SGaist said in Use existing windows project to create a dynamic library for iOS and Android?:

                Why would you need C in the first place since A is already a library ?
                A is a C++ library with core features. C would create logic to initialize classes in A and also export C-style function methods that can be called easily from Flutter/Xamarin app code. C would also allow Flutter/Xamarin to register callback functions with it, so when A notifies C of an event, it will invoke the callback method in Flutter/Xamarin.

                @SGaist said in Use existing windows project to create a dynamic library for iOS and Android?:

                You can't have all three projects in one .pro file.
                Correct, each project has a separate .pro file.

                @SGaist said in Use existing windows project to create a dynamic library for iOS and Android?:

                Subdirs is the correct solution.
                https://wiki.qt.io/SUBDIRS_-_handling_dependencies - this?

                How do I get a SUBDIRS project to generate android library using qmake? do I have to use qmake in android folder of Qt? anything else?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 10 Oct 2022, 18:30 last edited by
                  #8

                  If you want to build a project for Androïd, you need the Qt build for Androïd as well as the SDK and NDK. It's all explained in the Androïd Getting Started Guide.

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

                  T 1 Reply Last reply 10 Oct 2022, 20:58
                  1
                  • S SGaist
                    10 Oct 2022, 18:30

                    If you want to build a project for Androïd, you need the Qt build for Androïd as well as the SDK and NDK. It's all explained in the Androïd Getting Started Guide.

                    T Offline
                    T Offline
                    Taytoo
                    wrote on 10 Oct 2022, 20:58 last edited by
                    #9

                    @SGaist I've already followed the guide and setup Android environment. The problem is that at the end its shows how to build Android applications using Qt Creater. Whereas, I'm interested in building a shared library, primarily through commandline on windows. Can't figure out how to do that

                    1 Reply Last reply
                    0

                    1/9

                    4 Oct 2022, 14:55

                    • Login

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