Recent

Author Topic: TMSSQLConnection in MacOS Lazarus  (Read 679 times)

spoofy

  • Newbie
  • Posts: 4
TMSSQLConnection in MacOS Lazarus
« on: December 04, 2025, 11:28:08 am »
I am here in problem with Mac version of Lazarus (4.2 and 4.4). Working with one project which compiles good on Windows and Linux but on Mac there is not TMSSQLConnection which is important in this project.
I know that the TSQLConnector option is maybe solution, but that requires too many changes to the entire project. Is there a reason why the mentioned component is not available in the Mac version of Lazarus?
Thank you.

wp

  • Hero Member
  • *****
  • Posts: 13363
Re: TMSSQLConnection in MacOS Lazarus
« Reply #1 on: December 04, 2025, 11:42:10 am »
I am neither an expert in macOS nor in MSSqlServer. But looking at the registration unit of the SqlDB package ("registersqldb.pas" in (lazarus)/components/sqldb) this can be seen:
Code: Pascal  [Select][+][-]
  1. {$IF FPC_FULLVERSION >= 20601}
  2.   // MS SQL Server and Sybase ASE connectors were introduced in the FPC 2.7 development branch,
  3.   //  and backported to 2.6.1. Operating systems should match FPC packages\fcl-db\fpmake.pp      
  4.   {$IF DEFINED(BEOS) OR DEFINED(HAIKU) OR DEFINED(LINUX) OR DEFINED(FREEBSD) OR DEFINED (NETBSD) OR DEFINED(OPENBSD) OR DEFINED(WIN32) OR DEFINED(WIN64)}        
  5.     {$DEFINE HASMSSQLCONNECTION}         
  6.     {$DEFINE HASSYBASECONNECTION}        
  7.   {$ENDIF}
  8. {$ENDIF}  
This condition does not define "HASMSSQLCONNECTION" for macOS (DARWIN). It's been a very long time since FPC 2.7 was "new", a lot has changed since then. Why don't you just extend the {$IF by an "OR DEFINED(DARWIN)", rebuild the IDE and see what happens. If it goes wrong, just restore the old state and rebuild the IDE again. If it works, on the other hand, you found an out-of-date condition in the registration unit, and you should file a bug report.

Zvoni

  • Hero Member
  • *****
  • Posts: 3270
Re: TMSSQLConnection in MacOS Lazarus
« Reply #2 on: December 04, 2025, 12:14:53 pm »
I'm trying (and failing!) to wrap my mind around the fact, why a Mac-User would voluntarily try to connect to a Microsoft-SQL-Server.....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

spoofy

  • Newbie
  • Posts: 4
Re: TMSSQLConnection in MacOS Lazarus
« Reply #3 on: December 04, 2025, 03:59:56 pm »
This is a multiplatform database management client that, among other things, has the ability to connect to MSSQL. I have no problem removing that part of the code so that I can compile it, the question was more why it is available on Windows and Linux but not on Mac.
Why shouldn't someone using Mac OS be able/need to connect to MS-SQL?

Zvoni

  • Hero Member
  • *****
  • Posts: 3270
Re: TMSSQLConnection in MacOS Lazarus
« Reply #4 on: December 04, 2025, 04:02:42 pm »
Why shouldn't someone using Mac OS be able/need to connect to MS-SQL?
Because it's a hassle just to install the Client-Driver?
https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver17
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

spoofy

  • Newbie
  • Posts: 4
Re: TMSSQLConnection in MacOS Lazarus
« Reply #5 on: December 04, 2025, 04:10:49 pm »
I am neither an expert in macOS nor in MSSqlServer. But looking at the registration unit of the SqlDB package ("registersqldb.pas" in (lazarus)/components/sqldb) this can be seen:
Code: Pascal  [Select][+][-]
  1. {$IF FPC_FULLVERSION >= 20601}
  2.   // MS SQL Server and Sybase ASE connectors were introduced in the FPC 2.7 development branch,
  3.   //  and backported to 2.6.1. Operating systems should match FPC packages\fcl-db\fpmake.pp      
  4.   {$IF DEFINED(BEOS) OR DEFINED(HAIKU) OR DEFINED(LINUX) OR DEFINED(FREEBSD) OR DEFINED (NETBSD) OR DEFINED(OPENBSD) OR DEFINED(WIN32) OR DEFINED(WIN64)}        
  5.     {$DEFINE HASMSSQLCONNECTION}         
  6.     {$DEFINE HASSYBASECONNECTION}        
  7.   {$ENDIF}
  8. {$ENDIF}  
This condition does not define "HASMSSQLCONNECTION" for macOS (DARWIN). It's been a very long time since FPC 2.7 was "new", a lot has changed since then. Why don't you just extend the {$IF by an "OR DEFINED(DARWIN)", rebuild the IDE and see what happens. If it goes wrong, just restore the old state and rebuild the IDE again. If it works, on the other hand, you found an out-of-date condition in the registration unit, and you should file a bug report.
Unfortunately this fails because mssqlconn unit is not available in fpc for mac  :( .


https://forum.lazarus.freepascal.org/index.php?topic=61558.0

spoofy

  • Newbie
  • Posts: 4
Re: TMSSQLConnection in MacOS Lazarus
« Reply #6 on: December 04, 2025, 04:12:44 pm »
OK, thanks for the answers, now I understand the reason why the component is not in the mac version.
Thanks

zeljko

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: TMSSQLConnection in MacOS Lazarus
« Reply #7 on: December 04, 2025, 06:48:04 pm »
That works with mac, I had that problem more than year ago, but cannot remember what exactly I did in that case, but I remember that I've enabled mac in that define. I've installed dbeaver-ce on the mac, then wondered why it works with dbeaver and not in lazarus, bit of googling and found solution, but really cannot remember what I did (and that mac is far away from me atm, so no way to know what I've patched exactly).
EDIT: maybe it was odbc , really don't know, but I know that I've succesfully connected and grapped data from mssql db on mac.
« Last Edit: December 04, 2025, 06:51:46 pm by zeljko »

PascalDragon

  • Hero Member
  • *****
  • Posts: 6325
  • Compiler Developer
Re: TMSSQLConnection in MacOS Lazarus
« Reply #8 on: December 04, 2025, 09:07:37 pm »
Why shouldn't someone using Mac OS be able/need to connect to MS-SQL?
Because it's a hassle just to install the Client-Driver?
https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver17

FPC's TMSSQLConnection does not use the ODBC driver, but the FreeTDS library which is an Open Source implementation of the underlying protocol. In principle it should also be possible to compile that for macOS.

OK, thanks for the answers, now I understand the reason why the component is not in the mac version.

If you get your hands on a FreeTDS binary for macOS you can just copy the mssqlconn unit from FPC's source and compile it yourself.

zeljko

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: TMSSQLConnection in MacOS Lazarus
« Reply #9 on: December 04, 2025, 10:29:17 pm »
Well well, it is pretty possible that I've used freetds via macports :) Thanks @PascalDragon :)

Zvoni

  • Hero Member
  • *****
  • Posts: 3270
Re: TMSSQLConnection in MacOS Lazarus
« Reply #10 on: December 05, 2025, 08:26:26 am »
FPC's TMSSQLConnection does not use the ODBC driver, but the FreeTDS library which is an Open Source implementation of the underlying protocol. In principle it should also be possible to compile that for macOS.
Damn!
Forgot that.
Thx PD
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018