How To Create Ubuntu Application
Introduction and Background
In this article, I am more focussed to write about applications for Ubuntu platform. I have always wanted to write about the platform, SDK, features and more stuff ever since I started programming for Ubuntu, back 3 months ago. The platform is so catchy, even for script-kiddies, that even I was caught by its catchy features. I do not prefer writing apps where I have to use shell scripts too often. But, Ubuntu is an exceptional case for me though. I have not yet tried using C# or the open sourced .NET Core on Ubuntu but I am sure going to try it some day sooner, and I will update the article for that or write a new one for that one section.
There have been many questions related to Ubuntu programming, graphical UIs in Ubuntu, SDK for Ubuntu etc and I always wanted to make sure that I do share some of my knowledge as an article for community but I was always found busy in other projects and blog etc. that I was not able to actually write it. So, since I am free from any other job, project, I guess before starting my Masters in CS course I should write the article for Ubuntu starters. I am sure you would enjoy the SDK and the article as you read it.
Some light on Ubuntu itself
Ubuntu, if you are unaware of what it is, is a Linux (kernel and Debian) based operating system. So right under that GUI a Linux kernel is being used for the underground stuff. Linux kernel maintains the processes and the communication channels between the operating system and the machine hardware. Machine is totally abstracted from the operating system, and kernel is used (along with a few other stuff) to make sure that operating system runs on every ( selected or supported ) architecture of machines. For example, you can run Ubuntu on a 32-bits and 64-bits, x86 and other architectures. The processes seem to be alike and the applications that you make for one of the machine runs on other machine too which is running Ubuntu. Why? Because Ubuntu runs at a very high-level in the hierarchy, so the programs that run the application are abstracted from the machine. The OS in this state only acts as the virtual machine, with a byte-code (for example!) that runs in it. The byte-code is compiled to native machine code just-in-time ! Due to this fact, the code that you write once is executed on every machine because the virtual machine decides which code to be compiled as which instruction. The instructions for machines differ from one to another.
Some introduction of Linux
Ubuntu is a distribution of Linux, Linux was just a kernel, it is not an operating system. And that is exactly the difference between Linux and GNU. GNU was the project that lacked a kernel, until Linus Torvalds created Linux and GNU guys took that open-source kernel (which, still offers royalty to Mr. Linus) and completed their operating system project. Thus, Linux is the kernel, GNU is the operating system. So, if someone asks you to do something on a GNU based system, do not confuse it with "Hey, but I only know how to do that on a Linux".
For more: Well, that is it for now for Linux. If you want to learn more about Linux itself, go and read
- Minix 3
Background and a few books that you can get about Minix 3. - Linux
Background and history - GNU
After reading these, you will have an idea of what is Minix 3, how Linux started and how did it complete GNU. :-) I won't talk more on these, and will move on to Ubuntu for now.
Ubuntu—a Linux distribution
Linux alone would be a favorite operating system for the shell-lovers, and those with a craze for command-line interface. But, for ones like me, if there is no graphical user-interface and no way to click a button to open "This PC", the OS is not "my type". Right? There are many distributions of Linux kernel, many companies and organizations has invested their money and time in creating an operating system over Linux kernel. Linux kernel allows them to worry about the operating system and the programs and services that it will offer while kernel manages the low-level services, CPU interrupts, RAM management and other facilities. Latest versions of Linux include many bug fixes, security patches and other loophole fixes so that operating systems have to worry about the code on their ends.
Ubuntu is one of those distributions, and is mostly used on personal computers. Ubuntu is based on Linux (according to the website, and yes, many geeks, it is a Debian-based Linux distribution) and yes, you can use the same features that Linux has, those same user accounts and the commands. But Ubuntu just adds a graphical user-interface on top of that, plus a framework and design to support third-party applications to be developed and ported to the devices. Ubuntu is not just a desktop OS, but also provides services for:
- Web servers
- Smartphones
- Tablets
- Cloud management
- Quite other options are also available because it is not a one machine based OS.
In my opinion, the concept of Windows 10 is much like Ubuntu's infrastructure. One operating system to rule it all. So the applications that you create on one device are able to run on multiple devices, just the way Windows 10 applications work, they just need a few tinkering and they are ready to go.
As captured from this thread, where Ubuntu's architecture is discussed about, the following representation may suffice your needs of understanding the architecture.
Figure 1: Graphical representation of Ubuntu OS from a Linux point-of-view. Drawing the schema for every service and process is almost impossible in a single diagram.
Now, as already said, explaining and connecting each and every service provided in Ubuntu OS or the kernel is almost impossible. So, I will leave you with an abstracted overview that the levels come in a way, like, first there is Linux kernel (skip the machine), then a few services that continue to run and communicate with Linux kernel, then a few UI services that render the graphics on screen for the opened windows and tabs, after that comes your application. These services communicate with the kernel and kernel executes the commands on CPU.
Well, on other hand I have created a much simpler diagram that you may find easier to understand also.
Figure 2: An easier to understand, abstracted overview of Ubuntu OS.
In the above image you can get the overview of Ubuntu OS itself, now if that is some-what clear we can now continue to the main topic, Ubuntu SDK. In the next sections I will walk you through using Ubuntu SDK and how to create an application in Ubuntu SDK for Ubuntu OS.
Ubuntu SDK—Qt creator and a bunch of services
Ubuntu SDK is a collection of a few services that every SDK has, Ubuntu is a Linux based system so an IDE is not a fully-integrated IDE as Windows has, Visual Studio. Ubuntu didn't come with a full-featured IDE, but not anymore. Ubuntu OS also has a full-featured IDE (special thanks to Qt project) which includes:
- Text-editor with syntax highlighting.
Of course most of the programmers need it, the syntax highlighting includes JavaScript, C++, C and many other languages, including the QML (markup language for Qt applications). Qt is a most widely used IDE and framework for cross-platform development. Qt is used for Windows, Linux (Ubuntu, Debian and Android etc), Mac and mobile phone development. So it has to include the syntax highlighting for a wide-variety of languages.- C/C++
- JavaScript
- QML
- XML
- JSON
- etc…
- Compilers for languages.
Along with the compilers, it also comes with the markup language and JavaScript parsers.- QML allows you to integrate the client-side scripting using JavaScript. So the events are handled using JavaScript and the same pattern is used. Plus, the QML markup language is also so much easy that creating the GUI is not at all a problem.
- The integrated compilers for C/C++ make it easy to run and debug your application instead of having to execute separate commands for each of these processes.
- Compile the code
- Parse the markup
- Assemble the binaries
- Create a package
- Find the executables
- Run them to see what happens.
- In Ubuntu, you just have to run the application; or debug it.
- Debuggers
Should you run into any trouble with your application or whether you want to try out the application before publishing it, SDK contains the stuff required.- Debugger
- Profiler
- Emulators and devices
SDK also contains the stuff that would help you to create the emulators and devices, on which you can run the applications on. In this guide, I will use the device that I am using to run the app on.- You can create emulators for mobiles, desktop and other platform or architecture where you want your application to run.
- I will be using Desktop one only in this guide.
- Source control
If you are a team of developers working together to create a project, then you would need source control, every team needs it. Ubuntu SDK has a wide variety of source control ranging from git to Bazaar. You can chose the one that suffices your needs.- git is a most-widely used source control, it also allows you to host your code over GitHub. It is fast and is widely used by command-line programmers. Plus, there are many guides already provided for you to learn git.
- Bazaar is another source control which is mostly used in Ubuntu, I never stumbled upon it in Windows. But, I didn't find a way to create an account so look for that yourself. :-)
- Publishing tools
Ubuntu SDK also provides you with facility to publish the applications to Ubuntu Software Center. Where your application can be downloaded by thousands of users!
Note: There is a commercial version of applications provided, but since I am in Pakistan and do not have a PayPal account I have no idea how that would be done, but that is also simple. Just add the details for your account and they will pay you for the revenue that your application will make.
That is just an overview of Ubuntu SDK, but using Ubuntu SDK and installing it just really very easy. I do love Visual Studio, everyone does, but installing Ubuntu SDK is a very simple and easy task. The size of SDK is also very compact, so downloading the binaries won't take too much time. Installation is also very robust and fast that it doesn't really matter what you do, it would take at maximum of 10 minutes; depends on your network and machine.
Installing the SDK
I will assume that you are having Ubuntu installed. You can get Ubuntu SDK two ways,
- From the Software Center; where you get to only click a button, "Install" and it gets installed.
- or… From the terminal. Where the stuff is processed step-by-step and you are aware of how long it will take and what process is being executed.
I will share "how-to" of both of these procedures to make it clear for you, I personally prefer the terminal way of installing the SDK, they are just 3 commands and you get most of the stuff already fixed up for you!
1. Installing using graphical user-interface
First of all, a section for graphical user-interface lovers. The process is very easy, all you need to do is go the Software Center and install the Ubuntu SDK. Using the software center you would have to only click a single button. Rest of the stuff is managed by the software center itself.
Go to the developer tools, right under their find IDEs. Ubuntu SDK is categorized under there.
Figure 3: Ubuntu SDK listed in the IDEs category of Developer Tools section.
You should click on More Info to get more details on this. This window should come up,
Figure 4: Ubuntu SDK details and a button to Quick-Install it.
You should click on Install if you have gone through the details of this software product. Once you click on that, Ubuntu would ask you for your password to perform super-user actions. It would take some time, it requires both Internet and some time. It would have the SDK installed for you!
2. Installing from the terminal
This is my favorite method of installing the Ubuntu SDK. It doesn't take much time, but is very powerful and simple way, since it only requires a few commands to install the SDK for you!
Open the terminal from your machine and proceed with installing the SDK,
1. Add the SDK release PPA
$ sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
It will prompt you for a password, enter the password for your user account. Once that is done, proceed with the installation of the SDK package.
2. Install the SDK
Execute the following command to install the SDK:
$ sudo apt update && sudo apt install ubuntu-sdk
This would now look for the packages and other resources on the network to download and setup for the SDK. It does take some time and this is the step that will take most of the time. It depends on your network speed so make sure you have a good network, slow would also work, but slowly. :-)
Once that is finished, there is no other stuff required to worry about. The SDK is set up. Start it, the terminal way.
$ ubuntu-sdk
There you will have the SDK running in front of you. Yes, it is the Qt creator ported with a few more plugins to work with Ubuntu programming.
Figure 5: Ubuntu SDK start up screen.
In the next section I will walk you through different options that Qt creator (Ubuntu SDK) provides you with for developing the Ubuntu applications. The IDE has many features and many templates for applications that you can use to create the applications. The applications are of wide variety.
- Console applications
If you want to build a program that doesn't need any graphics or rendering, then you can create a simple C/C++ console application and write the logic for your application. - Services or templates
- Graphical user-interface apps
If you want to create applications that make use of graphics, then these are your options. - Non-Qt projects
When you need to use the native power of Ubuntu, you can create Non-Qt projects and write softwares that make use of native power for better performance.
The applications created in GUI mode, use QML as the markup language for user-interface and JavaScript as the handler for clients' interactions. C++ is used as a back-end language for processing complex algorithms and structures. In most cases, JavaScript will suffice for example in case of network requests etc. But in cases where you need CPU to be used, you can make use of C++ language at its best!
Points of Interest—future versions of post
Alright, I think this is enough for this post. Until now you have got the basic idea of Ubuntu SDK, Ubuntu and how to build the applications. You may also have got the understanding of SDK IDE's environment and other basic tools and packages. That was all this post was meant to provide you with.
In next post about Ubuntu SDK, I will show you how to build different applications on Ubuntu platform. Ubuntu is a very powerful platform to build applications on. From console-based, to services to GUI based applications. The GUI based applications, built using Qt are also very easy in Ubuntu SDK. The QML, C++ configuration and all of that stuff, is very easy and native to understand that even if you have never programmed for Ubuntu, or if you are a web developer you will still get your hands on Ubuntu, pretty quick!
See you in the later posts. :-)
How To Create Ubuntu Application
Source: https://www.codeproject.com/Articles/1065753/Developing-Apps-for-Ubuntu-using-Ubuntu-SDK
Posted by: guntergeopenceed.blogspot.com
0 Response to "How To Create Ubuntu Application"
Post a Comment