Author: Dean C7173
Last week, in the Part 1 of this blog post we have installed Ubuntu 16.04 LTS Server-edition into a VMWare Fusion virtual machine running on Mac. Now we are going to complete the configuration of the Ubuntu server, install all the prerequisites for deploying the Delphi application, and deploy “Hello World” Delphi app using the latest Delphi 10.2 Tokyo beta, as the product has not yet been released. This means that anything that I’m describing here might change in the final version of Delphi!
I’m a Linux newbie and the command-line world of server-side Linux really impresses me. I’m used to run those really big Windows virtual machines, that even on my relatively new Mac need time to start and stop. On the other hand, the VM with Ubuntu that I have just installed is almost exactly 3GB in size. It starts quickly and stops quickly. There is something to it:-)
The best source of information on how to configure Ubuntu for Delphi development is Craig Chapman’s blog post and last week’s “Delphi Linux Bootcamp” webinar with Craig. The only difference is that Craig is using Virtual Box, and not VMWare as his virtualization technology. Inside the Ubuntu the steps are almost identical.
The configuration for Linux development with Delphi is logically the same as deploying to Mac or to iOS. Delphi itself is a Windows application and requires Windows to run. I’m using Mac, that is why I need to have a separate Windows 10 virtual machine for Delphi. In the installation folder of RAD Studio, you will find “PAServer” subdirectory. There are installation files for installing PAServer on Mac, Windows, and Linux. Our objective is to take the Linux PAServer, and deploy and install it on Linux box. “PAServer” stands for “Platform Assistant Server”. It is a console app that needs to be running on a machine where you want to deploy, run and debug Delphi (and/or C++Builder) applications. The IDE needs to know the IP address of the machine where the PAServer is running. When you hit “Run” button inside of the IDE, the project gets compiled locally, and then it is sent to the remote machine for execution or debugging sessions.
The first thing is to check what is the IP address of the Linux machine. Enter “ifconfig” from command-line and make note of the IP address associated with the virtual Ethernet card.
The next step is to update and upgrade the currently installed version of Ubuntu software. The ISO image is created once in a while and in the meantime, Linux development never stops. That is why we need to run the following commands to get our installation up to date:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
The “sudo” command makes it possible to execute operations that would normally require being logged in as “superuser”. The “apt-get” is the installation program for working with Linux packages. Select “Yes” when you are asked to and in few moments your Ubuntu installation should be up to date.
The next step is to install all dependencies that “PAServer” requires. Enter the following command with the list of packages to be installed:
sudo apt-get install joe wget p7zip-full curl build-essential zlib1g-dev libcurl4-gnutls-dev
After this command completes execution we can clean up installation executing the following commands:
sudo apt-get autoremove
sudo apt-get autoclean
The Ubuntu installation is ready for PAServer installation. Now move to the machine where Delphi 10.2 is running. We will need a way to physically transfer the PAServer installation program to a Linux box. Following Craig’s recommendation, I have installed WinSCP tool. You can download it free from https://winscp.net/end/download.php. The installation is very fast and you can make the connection with the remote Linux machine.
In order to be able to connect from Windows to Ubuntu, we will also need to install a secure shell. Execute the following command on Ubuntu:
sudo apt-get install mysecureshell
Now the connection with WinSCP should be successful. Upload “PAServer19.0.tar.gz” file from Delphi installation directory to home folder on Ubuntu with WinSCP.
Now we need to unpack, install and run the PAServer. Execute the following command on Ubuntu:
tar xvf LinuxPAServer19.0.tar.gz
This will unpack PAServer and create some subdirectories. Enter the “PAServer-19.0” subdirectory where the PAServer executable is located and run it by executing “cd PAServer-19.0” and then “./PAServer”.
The PAServer is running and waiting for us to send some Delphi apps to be executed! Time to write the “Hello World” app for testing. Currently Delphi does not support building apps with GUIs for Linux, so in the “File – New” menu choose “Console Application” and enter just two lines of code to display the message and wait for any keystroke before closing the program.
In the “Program Manager” right-click on the “Target Platforms” node and add “64-bit Linux” platform to the project. Now right-click on the Linux target and choose “Edit Connection”. Here you need to enter the IP address of the Linux machine. Click on “Test Connection” to see if the connection can be made.
Now we can build, deploy and run our program. Click on the green arrow icon to run the app. The very first time we try to run the app, the IDE will download some files from the Linux machine that are needed for compilation. If there any messages to accept different versions of files, click on “Yes to All” and wait until the app is deployed and run.
Here it is! Delphi 10.2 console app running on Ubuntu 16.04 Linux server!
Happy Delphi coding for Linux and do not be afraid of penguins! Even if they are armed!
You can start Linux development on any Ubuntu version with the use of Best Low-Code App Builder .Try it out and make the most of it. Request a Free Trial here.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition