Navigation

    UBports Robot Logo

    UBports Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Support
    4
    10
    82
    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.
    • Pulsar33
      Pulsar33 last edited by

      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

      1 Reply Last reply Reply Quote 0
      • Pulsar33
        Pulsar33 last edited by

        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

        arubislander 1 Reply Last reply Reply Quote 0
        • arubislander
          arubislander @Pulsar33 last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • Pulsar33
            Pulsar33 last edited by

            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

            arubislander 1 Reply Last reply Reply Quote 0
            • arubislander
              arubislander @Pulsar33 last edited by

              @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.

              Pulsar33 1 Reply Last reply Reply Quote 1
              • Pulsar33
                Pulsar33 @arubislander last edited by

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

                1 Reply Last reply Reply Quote 0
                • Pulsar33
                  Pulsar33 last edited by

                  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

                  dobey 1 Reply Last reply Reply Quote 0
                  • B
                    Borim7 last edited by

                    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
                    • dobey
                      dobey @Pulsar33 last edited by

                      @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.

                      Pulsar33 1 Reply Last reply Reply Quote 1
                      • Pulsar33
                        Pulsar33 @dobey last edited by

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

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post