• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

How to (cross)compile my own C [+GTK] source code

Scheduled Pinned Locked Moved Support
10 Posts 4 Posters 941 Views 1 Watching
Loading More Posts
  • 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.
    • P Offline
      Pulsar33
      last edited by 25 Apr 2020, 16:44

      Hello,
      Being off-topic in guide-for-beginners-app-development-ubuntu-touch I create this new subject to move some posts here.

      The question was : how to reuse my own software sources, developed since a long time on desktop for terminal commands and other ones with GTK ?
      Is there a solution to (cross)compile, please ?
      Where can the include and libraries be found ?

      BR
      Pulsar33

      Thanks to @Lakotaubp for posts move

      Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
      Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
      Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

      1 Reply Last reply Reply Quote 0
      • P Offline
        Pulsar33
        last edited by 23 Apr 2020, 10:58

        Hi,
        This is fine for people knowing Clickable and QT and so on, or having time and fun to learn that ...
        But what about if I want to reuse my own software sources, developed since a long time for terminal commands and other ones with GTK ?
        Is there a solution please ?
        BR
        Pulsar33

        Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
        Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
        Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

        A 1 Reply Last reply 23 Apr 2020, 11:01 Reply Quote 0
        • A Offline
          arubislander @Pulsar33
          last edited by 23 Apr 2020, 11:01

          Hi @Pulsar33,

          Is this software written by you that you want to use on your own device(s)? Or is it software that you want to publish to the OpenStore too?

          πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
          Happily running Ubuntu Touch
          Google Pixel 3a (20.04 DEV)
          JingPad (24.04 preview)
          Meizu Pro 5 (16.04 DEV)

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pulsar33
            last edited by 23 Apr 2020, 15:25

            The first idea is to use some own programs for my own needs on my own phone. However, once validated, it is also possible to publish the source code if it can be useful to someone.
            Have a nice day
            Pulsar33

            Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
            Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
            Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

            A 1 Reply Last reply 24 Apr 2020, 07:06 Reply Quote 0
            • A Offline
              arubislander @Pulsar33
              last edited by 24 Apr 2020, 07:06

              @Pulsar33
              If just the source code is going to be made available, and there are no plans to publish binaries or such to the OpenStore, then a Libertine container might be a good fit for your command line tools. It might also work for your GTK tools, but that is more hit or miss.

              πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
              Happily running Ubuntu Touch
              Google Pixel 3a (20.04 DEV)
              JingPad (24.04 preview)
              Meizu Pro 5 (16.04 DEV)

              P 1 Reply Last reply 24 Apr 2020, 07:55 Reply Quote 1
              • P Offline
                Pulsar33 @arubislander
                last edited by 24 Apr 2020, 07:55

                @arubislander OK, thank you
                I'll have a look to Libertine solution.
                Have a nice day
                Pulsar33

                Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
                Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
                Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

                1 Reply Last reply Reply Quote 0
                • P Offline
                  Pulsar33
                  last edited by 25 Apr 2020, 07:04

                  Hello,

                  Unfortunaly, Libertine is another sort of container and isn't what I'm looking for. Here are the reasons why :

                  • I'm really paranoid and happy that UT has high confinement solution but if I need some own pieces of code, it's precisely because I want to overide these limitations, as well as I can do with Terminal. This doesn't create security breaks because it is my code and I would be the only one that knows it is there.

                  • I would be surprised if Libertine could run desktop applications without compiling them for my phone's processor. Even if this is the case, I need true code execution, not emulation.

                  I use Eclipse CDT to compile and debug my (desktop) code. I'm looking for tools and files needed to compile my code for UT.

                  • Can I cross-compile on my desktop with Eclipse (and how) ?
                  • Must I compile on the phone (and how) ?
                  • Where are the include files and libraries (including GTK) ?

                  Hope someone can answer.
                  Thank you and have a nice day
                  Pulsar33

                  Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
                  Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
                  Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

                  D 1 Reply Last reply 25 Apr 2020, 20:10 Reply Quote 0
                  • B Offline
                    Borim7
                    last edited by 25 Apr 2020, 12:21

                    When you can cross compile your programs you can copy them to your phone and run them.

                    How difficult this task will be depends largely what dependencies your programs have.

                    Before some time (Canonical was still working on Ubuntu Touch). I remounted the system rw and installed some programs via apt. Than they could be used in terminal like normal programs.

                    I do not know if apt can still be used, but with your own programs this should be a possible way. Maybe it is sufficient to have them only in your home directory.

                    By the way it should also be possible to build click apps with unconfined access. I never tried it my self, but I have used own build apps with extended privileges to access the sdcard in my phone.

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      dobey @Pulsar33
                      last edited by 25 Apr 2020, 20:10

                      @Pulsar33 You can use Libertine as a means to install the tools and compile your app, and then simply install your app into your home directory somewhere in the host. You can bind mount a sub-directory of the home directory, into the Libertine container.

                      Libertine does not emulate things. It is simply a way to get a chroot for using legacy apps and CLI tools, as the system root is readonly.

                      You don't necessarily need to compile on your phone. I don't know how Eclipse works for cross-compilation, but compiling in a container is better, because you can keep everything needed to build for another architecture, in a confined place, rather than mixing in with your host OS. At the most basic level to compile a helloworld.c example for armhf architecture, you can install the gcc cross compiler for armhf, and then for example just run gcc-cross-armhf helloworld.c -o helloworld to get a helloworld binary compiled for armhf arch (actual gcc executable may be named differently).

                      The include files are the same. However, when cross-compiling, the tools should be picking up the correct values for the other architecture to compile and link. You may also need to include additional dependencies in the installation of your app, as they may not be included in Ubuntu Touch.

                      P 1 Reply Last reply 25 Apr 2020, 23:33 Reply Quote 1
                      • P Offline
                        Pulsar33 @dobey
                        last edited by 25 Apr 2020, 23:33

                        @dobey Hum,
                        No sure I understand everything but I will try to analyze your proposal ... and come back.
                        Thank you.
                        Pulsar33

                        Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
                        Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
                        Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

                        1 Reply Last reply Reply Quote 0
                        4 out of 10
                        • First post
                          4/10
                          Last post