Compile C++ on phone



  • I've do in my tablet with UT from terminal:

    phablet@ubuntu-phablet:~$ sudo apt install build-essential
    

    and it works for me.



  • @ereus

    Unable to locate package. I've already tried a bunch of different ways to get it installed with no success.

    It seems some gcc packages are installed (gcc5.1 gcc5.4) so I'm not sure what to do on that front.

    @Giiba I'd like to be able to do it directly on the phone. My googlefoo is failing me. Do you have any suggestions on how to hack into the UT system to use GCC?



  • @kjhg84j9 said in Complie C++ on phone:

    Do you have any suggestions on how to hack into the UT system to use GCC?

    Create a libertine container, and install the packages in libertine. That is the supported way to install legacy apps/tools on UT. See https://docs.ubports.com/en/latest/userguide/dailyuse/libertine.html#shell-access

    Main thing to remember here though, is do not install or try to use sudo inside libertine. If you need a root shell, use libertine-container-manager exec to start a shell in the container as a fake root user. Otherwise use libertine-launch /bin/bash as in the docs, in the Terminal app, to get a shell as phablet user.



  • Also keep in mind that compilation puts the flash card under quite a stress, so you might reduce the lifetime of your phone gradually with every compile. I mean bigger ones, not helloworld.c ^^



  • @dobey - I thought you meant I could do it on the phone or libertine container. Either way, it works! Thank you!

    @Flohack - Thank you for your concern. I don't plan to compile everything on the phone, I just wanted to make sure it works and what to expect. I believe it's possible to compile it on my desktop for my phone then move the binary over. I haven't looked into this yet, still working my way though the C++ book.

    My goal is to build something like Google Messages (text from a web page) for my PinePhone that's on its way here. I strongly dislike picking up my cellphone when I'm already on my computer.

    Cheers!



  • @kjhg84j9 said in Complie C++ on phone:

    I believe it's possible to compile it on my desktop for my phone then move the binary over.

    Yes, or on your PineBook as you did before. However, the PineBook is probably an arm64 system, and if you did not install the necessary 32-bit packages and tools to cross-compile for 32-bit, then you likely built a 64-bit binary which will not run on a Nexus 5.



  • @dobey - Thank you!!! this was enough to get me on the right path. I have complied my highlow c++ game on my PineBook and it runs without any issue on the phone.

    You guys are very helpful! It would have taken me ages to figure this out on my own. thank you all!

    Next I'm Just going to finish my book, look into libdbus and libcurl. Then I'll start reading up on how to build Ubuntu Touch apps. I'll have everything up on gitlab eventually. cheers!



  • @kjhg84j9 I've used phablet-tools from my computer to unlock my tablet.
    And then,
    I've do "sudo apt update" and "sudo apt install build-essential".



  • @ereus This is not supported, so it's best not to generally advise people to do this. The rootfs is readonly and limited in space for a reason. In almost all cases, simply doing apt update will result in out of space errors. It is not this simple, not supported, and not advisable.



  • I would like to add my voice in support of what @dobey said.

    I appreciate that the solutions we suggest are 'what worked for us' when we were facing a similar issue. And we feel it is better to give advice that we know will work from our own experience, because we can answer any follow-up questions about that.

    But we should consider the potential risk of our proposed solution to leave the device in a state needing a reinstall of the OS to resolve any mistakes.
    Not only is that a bad experience for the user, it also gives the impression that the OS is much more fragile than it actually is.

    So please, when questions come up where the answer is installing additional command line utilities from the standard repo's. Let's point them to the Libertine documentation first. Libertine works brilliantly for commandline utilities and apps. It's the graphical applications that are more of a hit or miss.


Log in to reply