ODBC connection string for SQL Server?

My Computer: Mac Mini M2 Pro with macOS 14.6.1
iODBC Administrator has Version 3.52.16 (latest Version)
ODBC Driver 18 for SQL Server has Version 18.4.1.1 (latest Version)

If I try to connect with a User DSN I get first

And after pressing OK I get a popup with the following content:

[iODBC][Driver Manager]dlopen(/opt/homebrew/Cellar/msodbcsql18/18.4.1.1/lib/libmsodbcsql.18.dylib, 0x0006): tried: ‘/opt/homebrew/Cellar/msodbcsql18/18.4.1.1/lib/libmsodbcsql.18.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/msodbcsql18/18.4.1.1/lib/libmsodbcsql.18.dylib’ (no such file), ‘/opt/homebrew/Cellar/msodbcsql18/18.4.1.1/lib/libmsodbcsql.18.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’))

Microsoft says on https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16

So I decided to test only Version 18 of the ODBC driver.

That is suggesting that your ODBC core in x86 and needs to be upgraded to work with your native Drivers.

I thought I was doing the right thing by installing the ARM64 drivers on my MacMini M2 Pro. This was done automatically with the Microsoft installer.
Now it looks to me that the ODBC Driver Manager has X86_64 and can’t do anything with an ARM64 driver.
Microsoft says that it will install the X86_64 driver if the command prompt is running in X64 emulation mode. How do you do that? This is a mystery to me.

I would suggest removing the x86 core and attempt to reinstall that. If the machine is ARM then it all should be ARM.

The Microsoft-provided ODBC driver for Mac is compiled using the unixODBC library standard (used by most of the Linux world). Most Mac ODBC-enabled applications (including the Xojo plugin, MS Excel, FileMaker, etc) are compiled using the competing iODBC library standard. Because of this, nearly all ODBC drivers on the Mac are compiled using iODBC. An iODBC application cannot use a unixODBC driver.

Jonathan

1 Like

Finally decided to try the Monkey Bread plugin MS SQL Plugin as an alternative to using the Microsoft driver and XOJO SQL plugin.

It works as soon as I matched the architecture of the MACOS build setting to the architecture of FreeTDS driver that you need to install.

Christian provides a sample app that I started with and I just changed the architecture to “ARM 64-bit” and then copied the driver file (libtdsodbc.dylib for “Mac 64-bit ARM”) and substituted my connection information for SQL Server and it connected and I was able to select a rowset without any problems.

For $ 149 it’s a steal when you consider how much time I’ve wasted trying to use MS’s driver.

I’m uploading a copy of the sample project with some slight mods that I made. You download the FreeTDS driver from here.

Questions?
Microsoft SQL via ODBC on Mac.zip (11.5 KB)

2 Likes

I should one little issue I ran into with the Copy File Step in my build settings. I had to put the libtdsodbc.dylib driver in the MacOS folder of my debug build. It would not load it if I put it in the Resources folder. Just wanted to add that.