FPC

Hello everyone, who doesn't know my name Sergey! And in the next article I will touch upon the development of Object Pascal.

At present and Delphi And FPC/Lazarus (FPCfree pascal compiler, LazarusIDE) support assembly for different platforms.

In this article I will introduce you to the development possibilities Android-applications by means of FPC/Lazarusincluding games. And I'll also add a little information on Delphito make it easier to find the information you need if you use this development environment, but for the development itself in Delphi For Android I can't give you enough necessary information at the moment.

Introduction

I came across the possibility of creating quite by chance Android-applications for FPC/Lazarus and I've come a long way to more or less understand how everything is arranged and works. During the time that I've been developing a cross-platform library ZenGL V FPC/Lazarus quite a bit has changed and been improved for the convenience of users. At the moment, as before, the most difficult thing remains to set up the environment for creating Android-applications (we are not talking about Delphieverything seems to come out of the box).

Here you can watch the videos I posted while learning Android development.

Just starting out and this was, at the time, the easiest way for me to use the ability to use a cross compiler to create Android apps. Used CodeTyphon.

Next I make a native application using SO libraries. It is used Eclipsebut now you can do the same for Android Studioor rather even simpler. You need to watch either rewinding or at high speed. Showed the full process and still very poorly knowing java. )))

Below is some slightly outdated information on creating an APK application using ZenGL. It was still in use at that time. Eclipse. But it is quite possible that the information will be useful to someone.

Throughout the entire time that I have been developing ZenGLit becomes clear that FPC/Lazarus not very suitable for beginners to develop applications for Android. And even with a lot of information, it still causes difficulties for beginners, and therefore I do not advise people who are not ready to put in the effort to set up a development environment and who need a ready-made solution to do this.

Some people might find this process interesting, but most people will find it off-putting, especially if you don't program in Pascal.

A little bit about Delphi

I don't use Dlphi for Android for the simple reason that I haven't seen any examples that make it possible to create sufficiently native applications. But recently came across an example and there is a high probability that I will add the ability to assemble ZenGL projects for Delphiif these examples actually contain such a possibility.

The development environment allows you to build projects under Windows, Linux, MacOS, Android And iOS.

I hope I haven't missed anything, if I have, I hope people will add to this point.

This environment works with two languages. C++ And Object Pascal. Let's not argue about this, personally I think that Delphi is not a language, but a development environment. This is my personal subjective opinion! )))

Several books have been published on working with Delphisome of them also talk about mobile development:

  • Dmitry Osipov “Delphi XE2”, 2012

  • Vsevolod Leonov “Training in mobile development on Delphi”, 2014-1015

  • Rubancev Valery “The Big Self-study Guide Delphi XE3”, 2013

  • Dmitry Osipov “Delphi. Programming for Windows, OS X, iOS and Android”, 2014

Well, that's it for my review, so to speak. By the way, don't forget to check out the site Embarcaderothere you may well find the information you are interested in.

FPC/Lazarus Requirements and Capabilities

FPC allows you to build applications for multiple platforms, you can read about it Here.

Primary requirements for development under Android at the moment it is FPC older than version 3.0.4.

A little about FPC.

In fact, the first versions of FPC that collected code for Android applications were made quite a long time ago and their version is somewhere around 2.6.n – 2.7.n (I may be wrong). But at this time there have been many updates and changes, so it is not recommended to use a version below 3.2.0.

Lazarus. In this case, choose one of the latest and stable versions. In most cases, the choice of versions is not critical, and often the latest versions carry additional functionality. There is a small problem with Lazarusthere may be incompatibilities in transitional versions and the project you created may not open in another version Lazarus. In such cases, some versions have a field for compatibility with old projects, which does not solve problems with new projects. I do it my way: I delete the file *.lpi and I open it in Lazarus file *.lpras a result of which Lazarus creates the necessary one himself *.lpi the file and project open normally (but this does not mean that some projects will not glitch as a result of this).

I recently did a short review of the Lazarus IDE. It might be useful for beginners.

From the moment when FPC started collecting code for Androidpeople started writing a lot of applications and developing this direction.

laz4Android – assembly for Lazarus which “comes by default” in many cases. Was one of the first.

LAMW – a project that uses laz4Android and this project is installed in Lazarus and has its own components for development Android-applications (visit forumit may contain very little information). Be careful, this project in a certain revision may not be stable and you need to consult with the developer for corrections or use an earlier version LAMW. It is also not compatible with standard LCL-components. But this does not change the fact that it is quite easy to work with.

Custom Drawn Interface/Android – a set of graphical interfaces based on native Android. Most compatible with LCL. As I understand it, it currently has almost no support.

LazToAPK – there is little to say about this project, but it is positioned as a project to help install the necessary components.

FPCUPDeluxe – graphical installer for FPC And Lazarus. With its help you can install on Windows, Linux And MacOSFPC/Lazarus and also download, install and configure the cross compiler, including for Android.

Castle Game Engine – a project that allows you to create games for Android. In fact, for many platforms using Object Pascal.

ZenGL – a cross-platform library (framework) that allows you to create applications and 2/2.5D games (3D is also possible if you know OpenGL) without knowledge of any graphics libraries. You can familiarize yourself with the main features here link.

I won't be able to introduce you to all the libraries in one article, but if you are interested, then go to Free Pascal Wiki and there you can pick up quite a bit of information. A little advice, read not only Russian or only English branches, but alternate them. Some information may be outdated on some branch, and some may be useful. Although for the most part, they coincide most.

Setting up the development environment

For development under Android I use OS Linux and I got very used to it, so my subjective opinion may flash somewhere. I apologize for this!

First you need to install FPC And Lazarus. You can also use CodeTyphon (if you use CodeTyphon, you can simply skip some of the information below).

Install FPC possible according to wiki. After downloading the installation files Lazarus Here or with home page (FPC is included). And also using FPCUPDeluxe.

Personally, for beginners, I would recommend using FPCUPDeluxesince it is a graphical shell and, for the most part, it already does the necessary actions, without forcing you to go into unnecessary details.

I am attaching a video where I quickly run through the installation. FPC/Lazarus by using FPCUPDeluxe and I also show an example of how it can be done Windows install the cross compiler in another way.

Although in fact there are already a lot of examples to prepare for FPC/Lazarus to work with Androidbut there is still a lot of uncoordinated information on building a cross compiler. You can, ultimately, build it yourself by simply downloading everything you need from GitLab. But I think few people will be able to take advantage of this opportunity (although even having downloaded the source code from there, a lot can be done practically automatically, there are hints there). And for this very reason I advise using FPCUPDluxe.

You also need to install it Java. Without Javaunfortunately, is not possible at the present time in mobile development.

Next I would advise to simply install Android Studio and not think about anything. It usually comes with SDK And NDK (I'm not entirely sure about NDK, it may well need to be installed additionally). Or you will need to install SDK And NDK separately.

But it is quite possible for many Android Studio will be needed to test the native code. Therefore, you choose what exactly you will install.

At present, all the necessary paths have been pulled up for me by themselves; previously, I had to indicate them for FPC/Lazarusso this also requires verification.

You can see some information on building a cross compiler Here, Here or Here. And also a lot about installing the cross compiler is described on the site Castle Game Engine.

Please note that if you have difficulty with any of the methods, you can use the hints on the other links. Many of them are similar and/or complementary to each other.

Creating and assembling projects

If you use LAMWthen the creation and assembly of the project is no different from the usual creation of a project in Lazarus. The simplest example can be seen at GitHub. Let me remind you that such applications are not compatible with LCL applications!

This is roughly what it will look like:

We create a project

We create a project

The settings window (looks a little different in Windows)

The settings window (looks a little different in Windows)

And the final project itself. Showed what tabs there are for creating an Android application

And the final project itself. Showed what tabs there are for creating an Android application

At the end we compile the project and get an APK or AAB file.

LAMW – is one of the most popular libraries for development Android-applications, but I don't use it… It's very good for creating a regular application, like LCL for Windows, Linux or MacOSBut it's not very well suited for making games.

Suitable for creating games for Android Castle Game Engine, ZenGL and… oddly enough SDL… Although in fact there were quite a few engines for creating games, you can look at FreePascal wiki some of the engines. Some of them could create projects just for Androidbut many are simply abandoned.

WITH SDL many are familiar and everything necessary needs to be looked at website and mix it with the information on the site Free Pascal meets SDL. Someone does it Pascal games for Android using SDL I can't say, I haven't seen it. But games using SDL And Pascal they do it at all.

Castle Game Engine – it is a fairly powerful and developing graphic engine. And all the information should be sought on their website, in documentationtheir forum or other sources. I tried it at one time, I didn't like it very much, but that's my personal opinion! Some games made on CGE work on Android.

ZenGL – a fairly minimalistic engine. To prepare the engine for work with Android I painted Here and there is also a description of how to run demos. The link indicates what is used Eclipsebut is currently in use Android Studio for the final assembly of projects. You need to perform the same actions as for Eclipseonly the folder is different for demo versions now.

Inconvenience ZenGL that there are no graphical environments for it where you can place any elements and everything must be done manually. And also for all your new projects you need to register the paths to the modules ZenGL and settings files. Well, this engine is mainly made for 2/2.5D. It is also possible to make 3D applications, but for this you need to know OpenGL.

Pros: fairly easy to create simple 2/2.5D games; does not require knowledge of graphics libraries (if you use the tools of the ZenGL); not small enough functionalwhich is not only related to graphics.

Video of a project being built using Android Studio

Related

When I started working with Android, I studied methods of interaction between native code and Java code. An example from the video, where work is done with the transfer of arrays from Java code to native and back.

An example of how you can work with logs:

Results

As you can see FPC/Lazarus have quite a few opportunities to create Android-applications.

The advantages include:

  • After setting up everything necessary to create projects, you often don't need to use other IDEs. Everything can be assembled directly in Lazarus and tested immediately.

  • Craftsmen can develop an application in a specific IDE and build it for all supported (and unsupported, if desired) platforms at once. For this, there are ready-made settings somewhere, and somewhere you will have to make your own settings for the project.

Cons:

Although in most cases, creating applications for Android always requires a lot of routine work and additional settings. The only exception is probably Android Studiowhere (it seems) everything is initially included.

I hope the material will be useful for both beginners and not so beginners. I hope I didn't forget to mention anything, although I probably did.

All the best!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *