Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt creator + Android + clang

Qt creator + Android + clang

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
8 Posts 4 Posters 4.5k Views
  • 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 Offline
    M Offline
    MirkoSerra
    wrote on 28 Sept 2018, 15:02 last edited by
    #1

    Before anything, Hi to everyone. First time posting at this forum.
    I'm having some problems porting existing code to Qt for Android. Downloaded Android SDK + NDK, used it fine. Then downloaded Qt Creator, started porting the App and could get it to work on Android. Kinda. I replaced the gprc part by a mock, and it worked.
    Now, I'm trying to get it to work and it's being quite a mess.

    Compiled the grpc libraries part basing on the grpc Android example. I got it to work. But when linking, I got symbols not found errors, apparently because Qt Creator is using GCC (it shouldn't, it's deprecated on Android NDK long time ago), whereas the grpc example uses clang and both compilers are using different name mangling systems.

    So, I tried to switch the project to clang. It just doesn't work.

    For starters, even when clang is a part of the Android NDK, it doesn't get detected by QT Creator. Fine. Then, even when I add it manually, I dont have an "Android Clang" option like there is for "Android GCC". Fine. I will add it as a compiler manually.

    I added the compiler under tools/kits/compilers:
    0_1538145979265_1.png

    I tell Qt Creator that there's a clang at that route, and that it should compile for that architecture (same settings I've used to recompile Qt libraries). Sill don't know where a lot of flags come from (they're not in this pane and can't seem to configure them from here, but w/e).

    Then I configure the kit:
    0_1538146100942_2.png

    And I tell Qt Creator that this kit comes with that compiler.

    Next I configure my project to use that kit

    Then I clean, run qmake and when I press build, it builds with plain clang++ (from path, instead of the provided one) and without the target flags (tries to compile for x86_64 and that doesn't work because I have static asserts that catch structures sizes incorrectly configured, namely time_t is 64 bits instead of 32).

    I was able to "force" it to compile with such a compiler setting QMAKE_CXX and adding -target armv7-none-linux-androideabi to QMAKE_CXXFLAGS (awful and kills the multitarget part), but then "I get Relocations in generic ELF", which led me to thing I'm still missing more settings (like -fPIC), but I want to know what I am doing wrong regarding to setting the compiler/kit instead of keeping banging my head against a very hard wall.

    Thanks.

    K 1 Reply Last reply 28 Sept 2018, 15:20
    0
    • M MirkoSerra
      28 Sept 2018, 15:02

      Before anything, Hi to everyone. First time posting at this forum.
      I'm having some problems porting existing code to Qt for Android. Downloaded Android SDK + NDK, used it fine. Then downloaded Qt Creator, started porting the App and could get it to work on Android. Kinda. I replaced the gprc part by a mock, and it worked.
      Now, I'm trying to get it to work and it's being quite a mess.

      Compiled the grpc libraries part basing on the grpc Android example. I got it to work. But when linking, I got symbols not found errors, apparently because Qt Creator is using GCC (it shouldn't, it's deprecated on Android NDK long time ago), whereas the grpc example uses clang and both compilers are using different name mangling systems.

      So, I tried to switch the project to clang. It just doesn't work.

      For starters, even when clang is a part of the Android NDK, it doesn't get detected by QT Creator. Fine. Then, even when I add it manually, I dont have an "Android Clang" option like there is for "Android GCC". Fine. I will add it as a compiler manually.

      I added the compiler under tools/kits/compilers:
      0_1538145979265_1.png

      I tell Qt Creator that there's a clang at that route, and that it should compile for that architecture (same settings I've used to recompile Qt libraries). Sill don't know where a lot of flags come from (they're not in this pane and can't seem to configure them from here, but w/e).

      Then I configure the kit:
      0_1538146100942_2.png

      And I tell Qt Creator that this kit comes with that compiler.

      Next I configure my project to use that kit

      Then I clean, run qmake and when I press build, it builds with plain clang++ (from path, instead of the provided one) and without the target flags (tries to compile for x86_64 and that doesn't work because I have static asserts that catch structures sizes incorrectly configured, namely time_t is 64 bits instead of 32).

      I was able to "force" it to compile with such a compiler setting QMAKE_CXX and adding -target armv7-none-linux-androideabi to QMAKE_CXXFLAGS (awful and kills the multitarget part), but then "I get Relocations in generic ELF", which led me to thing I'm still missing more settings (like -fPIC), but I want to know what I am doing wrong regarding to setting the compiler/kit instead of keeping banging my head against a very hard wall.

      Thanks.

      K Offline
      K Offline
      koahnig
      wrote on 28 Sept 2018, 15:20 last edited by
      #2

      @MirkoSerra

      Hi and welcome to devnet forums

      You cannot switch the compiler from GCC to CLANG just by adding the compiler.

      All Qt libraries are typically pre-built and simply pulled from a repository during the installation process. The number of different builds is limited. Therefore you cannot simply install Qt libs for a compiler of your preference. You would need to the compiler of your preference and build Qt libs respectively the dynamic libs by using that compiler. When the build was successful you can include this build and use it for building your applications based on Qt libs.

      For instance there are a couple of different prebuilds available on windows, but MinGW 64 bit is not included in the prebuilds and has to be compiled when you decide to requrie a 64 bit build.

      Here are some details for Qt on Android AFAIK nobody has tried to compile Qt on his own. At least it is not reported AFAIK. This does not mean that it is not possible, but guidelines may be missing.

      This is merely a user driven forum and Android is merely implementation driven compared to other parts. Therefore, I would suggest to you that post also in the qt-android forum on google for getting support in building Qt libraries with an additional not directly compiler.

      Vote the answer(s) that helped you to solve your issue(s)

      M 1 Reply Last reply 28 Sept 2018, 17:51
      2
      • K koahnig
        28 Sept 2018, 15:20

        @MirkoSerra

        Hi and welcome to devnet forums

        You cannot switch the compiler from GCC to CLANG just by adding the compiler.

        All Qt libraries are typically pre-built and simply pulled from a repository during the installation process. The number of different builds is limited. Therefore you cannot simply install Qt libs for a compiler of your preference. You would need to the compiler of your preference and build Qt libs respectively the dynamic libs by using that compiler. When the build was successful you can include this build and use it for building your applications based on Qt libs.

        For instance there are a couple of different prebuilds available on windows, but MinGW 64 bit is not included in the prebuilds and has to be compiled when you decide to requrie a 64 bit build.

        Here are some details for Qt on Android AFAIK nobody has tried to compile Qt on his own. At least it is not reported AFAIK. This does not mean that it is not possible, but guidelines may be missing.

        This is merely a user driven forum and Android is merely implementation driven compared to other parts. Therefore, I would suggest to you that post also in the qt-android forum on google for getting support in building Qt libraries with an additional not directly compiler.

        M Offline
        M Offline
        MirkoSerra
        wrote on 28 Sept 2018, 17:51 last edited by
        #3

        @koahnig Thanks, I did recompile QT libs with clang before doing this.

        P 1 Reply Last reply 28 Sept 2018, 17:53
        0
        • M MirkoSerra
          28 Sept 2018, 17:51

          @koahnig Thanks, I did recompile QT libs with clang before doing this.

          P Offline
          P Offline
          Pablo J. Rogina
          wrote on 28 Sept 2018, 17:53 last edited by
          #4

          @MirkoSerra just in case, you may want to use an "older" NDK that still has GCC provided. See this post for more information.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          M 1 Reply Last reply 28 Sept 2018, 19:01
          1
          • P Pablo J. Rogina
            28 Sept 2018, 17:53

            @MirkoSerra just in case, you may want to use an "older" NDK that still has GCC provided. See this post for more information.

            M Offline
            M Offline
            MirkoSerra
            wrote on 28 Sept 2018, 19:01 last edited by
            #5

            @Pablo-J.-Rogina Thanks. In the NDK I have both compilers. The problem is QT (creator's build system and qt libraries) uses gcc, GRPC uses clang (in line with new Android requirements). Project uses both libraries, so need to compile everything with one compiler. Already compiled Qt libraries with clang. But Qt creator isn't letting me compile the project with clang.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Sept 2018, 19:06 last edited by
              #6

              Hi and welcome to devnet,

              Did you check whether your NDK's GCC is not just a symlink to clang ?

              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 28 Sept 2018, 21:15
              0
              • S SGaist
                28 Sept 2018, 19:06

                Hi and welcome to devnet,

                Did you check whether your NDK's GCC is not just a symlink to clang ?

                M Offline
                M Offline
                MirkoSerra
                wrote on 28 Sept 2018, 21:15 last edited by
                #7

                @SGaist It is not, but if it were, I would have no problems. The thing is, symbols differ from one compiler to the other because they're different.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 28 Sept 2018, 21:21 last edited by
                  #8

                  Which version of the NDK are you using ?

                  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

                  7/8

                  28 Sept 2018, 21:15

                  • Login

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