Easy install SQL Server driver in Ubuntu
It's quite exciting to develop Delphi and C++ Builder applications for Linux using the brand new RAD Studio 10.2 Tokyo release. So I can imagine that many developers are now starting new projects targeting Linux, or adapting their existing ones to the new platform.
Many of these projects will surely use database connections, and the most widely used Enterprise database engine is Microsoft SQL Server (acording to different surveys).
I set up a new Ubuntu Server 16.04 (following the great guides by PAWEŁ GŁOWACKI here and CRAIG CHAPMAN here). But when I started to develop a sample Linux application that connects to an SQL Server database, I found some problems to get the application connecting without issues to the server.
First of all, the documentation that explains the steps to install the necessary drivers is split in two docwiki pages: UnixODBC_(FireDAC) and Connect_to_Microsoft_SQL_Server_(FireDAC) (I have to admit that with the excitement of the new development, I missed the first link :) ). There are a few steps in each of the pages, so it takes some time to get all things set up.
Then I launched the application and I got this error:
EFDException: [FireDAC][Phys][ODBC]-314. Cannot load vendor library [libodbc.so]. Hint: check it is in the PATH or application EXE directories, and has x64 bitness.
I followed all the steps again with no success. So I prepared a new Ubuntu Server installation, installed the drivers again with the same result.
With the invaluable help of my very good friend Agustín Terol, we found that some libraries were still missing in the system: the FreeTDS ones. After installing those libraries and a few tweaks here and there, we got the application running successfully.
Then we prepared a simple script file, that everyone could execute and get easily their systems ready to connect their Delphi and C++ Builder applications to a MS SQL Server database. Of course, this script is for Ubuntu systems. You can download the script here. Disclaimer: use at your own responsibility, it's not guarantee that this script works in every system, and it's not our responsibility any undesired effects that may cause in your system.
In resume, to get an Ubuntu Server 16.04 ready to run SQL Server-based applications, follow these steps:
- Get your Ubuntu Server installed following any of these guides: Preparing Ubuntu 16.04 LTS for Linuxdevelopment or Configure Delphi and Redhat or Ubuntu for Linux development
- Get the script into the Ubuntu server using any of these instructions:
- Download it using wget in the command line: wget community.embarcadero.com/uploads/11274/04_sqlserver_driver/sqlserverdriver.tar
- Or copy it to the server using the WinSCP tool
- Extract the script file from the sqlserverdriver.tar, usign the following command: tar xvf sqlserverdriver.tar
- Execute the script: ./sqlserverdriver.sh
- After a few minutes you will get your system properly configured.
Here there are a couple of screenshots that show the same application running on Linux and Windows:
With this environment I can easily develop and deploy REST-based microservices in Linux that connect to MS SQL Server, or applications that execute scheduled jobs (to send e-mails, perform billing, ...), or use RAD Server connecting to SQL Server, etc... There is a huge ammount of amazing oportunities by developing for Linux with RAD Studio 10.2 Tokyo, don't miss them!!
Please login first in order for you to submit comments