ODBC Driver 17 for SQL Server on apple M1

Viewed 4060

I am trying to get ODBC Driver 17 for SQL Server to work but somehow it doesn't on my brand new apple M1. Apparently I got unixodbc installed and also the driver, but starting them doesn't work. Looks like the odbc driver is not yet ready for the architecture (see below output). Doesn't even look like an issue with the microsoft driver, but the general lib from unixodbc - am I correct?

Any ideas if it's possible to compile this on my own?

XXX@M1 ~ % odbcinst -j
unixODBC 2.3.9
DRIVERS............: /opt/homebrew/etc/odbcinst.ini
SYSTEM DATA SOURCES: /opt/homebrew/etc/odbc.ini
FILE DATA SOURCES..: /opt/homebrew/etc/ODBCDataSources
USER DATA SOURCES..: /Users/XXX/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
XXX@M1 ~ % sqlcmd
dyld: Library not loaded: /usr/local/lib/libodbc.2.dylib
  Referenced from: /opt/homebrew/bin/sqlcmd
  Reason: no suitable image found.  Did find:
    /usr/local/lib/libodbc.2.dylib: mach-o, but wrong architecture
    /usr/local/lib/libodbc.2.dylib: mach-o, but wrong architecture
    /opt/homebrew/Cellar/unixodbc/2.3.9/lib/libodbc.2.dylib: mach-o, but wrong architecture
    /opt/homebrew/Cellar/unixodbc/2.3.9/lib/libodbc.2.dylib: mach-o, but wrong architecture
1 Answers

I'm not familiar with odbcinst, but in general when running things from the terminal on Apple Silicon (M1), if the libraries are not universal, you have two choices:

  1. set Terminal to run on Rosetta2, or
  2. prefix your command with arch -x86_64

I would suggest you try

arch -x86_64 odbcinst -j

Read more about this here. (Yes, the link speaks about Flutter, but the solutions are the same.)

Related