Delphi and CentOS 7
In recent years, Embarcadero expanded Delphi to cover the Linux platform as target platform for projects. In this step, two distributions of Linux are supported: RedHat and Ubuntu.
There are more than enough resources available on the internet that provide step-by-step instructions and explain how you can configure Delphi IDE to build projects for these Linux distributions. The official documentation is very good example but, also, this article has a very detailed guide on the topic.
Unfortunately, CentOS, another popular distribution of Linux was left out. Although CentOS is a very close cousin of RedHat (which is supported by Delphi) you know how things are in the Linux world….total mess. Every distribution sets its own rules, folder structure, package names, etc and the end result is the total absence of standardisation.
Delphi users who want to compile for CentOS will very soon find out that setting up the SDK manager for CentOS may not be as easy as for Ubuntu. The main goal is to make sure that SDK can find the necessary files to build a project for Linux.
I spent some time digging into the files and directories of CentOS (I use version 7) in an effort to figure out how I can make Delphi use CentOS to build my projects. The conclusion is that I had to manually edit the folders SDK recognises and, consequently, uses to build the cache for CentOS SDK.
Fixing the Folders
This is how to create a SDK version for CentOS:
- Create a new Connection Profile the usual way and connect via PAServer to the machine with CentOS
- Create a new SDK version, select Linux as platform and the profile you created in step 1. The manager should be able to retrieve the information of the SDK (please note you need to have PAServer running in the Linux machine)
- When you click OK, Delphi will start downloading files from the Linux machine. You can cancel this or let it finish with errors
- Use the buttons in the right-hand sidebar in the Remote Paths list and edit the paths to meet CentOS folder stucture. You can see the paths in the following table (CentOS 7)
CentOS 7 Paths Include Paths $(SDKROOT)/usr/include $(SDKROOT)/usr/include/gnu $(SDKROOT)/usr/include/c++/$(GCCVERSION) $(SDKROOT)/usr/include/c++/$(GCCVERSION)/x86_64-redhat-linux $(SDKROOT)/usr/lib/gcc/x86_64-redhat-linux/$(GCCVERSION)/include Library Paths $(SDKROOT)/usr/lib/gcc/x86_64-redhat-linux($(GCCVERSION) $(SDKROOT)/usr/lib/gcc/x86_64-redhat-linux($(GCCVERSION)/include $(SDKROOT)/usr/lib64 $(SDKROOT)/lib64
- Click on the Update Local File Cache button to reload the files and update the SDK
Now, you should be able to add CentOS in a project as the target platform as in the picture below.