64-bit ODBC

64-bit ODBC primer — when to use a 64-bit ODBC driver; ODBC issues on 64-bit Linux, UNIX and Windows platforms; background information on 64-bit architecture, operating systems and programming models.

Contents

Introduction

32-bit computer hardware is based on a processor capable of manipulating 32 bits (binary digits) of information at a time and using 32 bits to represent memory addresses. 64-bit hardware uses 64 bits to do the same thing. Usually, 32-bit operating systems run on 32-bit hardware, although it is possible to run 32-bit operating systems on some 64-bit computers. 64-bit operating systems run on 64-bit hardware.

Operating systems consist of a kernel (which allocates system resources, launches applications and manages memory, files and peripheral devices) and operating system libraries. 32-bit operating systems have a 32-bit kernel. 64-bit operating systems have a 64-bit kernel. Some operating systems, for example Solaris 7.0+ and AIX 5, can boot either a 32-bit or a 64-bit kernel. A 64-bit kernel is required to run 64-bit applications. (On AIX 5, IBM state that 32-bit and 64-bit applications can run with either a 32-bit or 64-bit kernel. However, for applications that use kernel extensions, this is conditional on the support for the extension in both kernels.) An operating system with a 64-bit kernel can also run 32-bit applications.

Operating system libraries are required to build and run applications. To build 32-bit applications, they must be linked to 32-bit system libraries. To build 64-bit applications, they must be linked to 64-bit system libraries.

32-bit applications are compiled such that memory addresses are 32-bit (4 bytes) in size. These applications can directly access up to 4 GB of virtual memory (the memory potentially available for use on a computer, which may be partially simulated by secondary storage such as a hard disk). This virtual memory limit is present regardless of the amount of physical memory installed on the machine. By contrast, 64-bit applications are compiled such that memory addresses are 64-bits (8 bytes) in size and can use more than 4 GB of virtual memory.

64-bit applications require a machine with a 64-bit processor and a 64-bit operating system. 32-bit applications can be run on both 32-bit and 64-bit machines/operating systems. However, only 64-bit applications can take advantage of the 64-bit capabilities of the processor and operating system. Depending on the application, these may include the 64-bit memory addressing and arithmetic capabilities of the processor, as well as increased system resources provided by the operating system.

Advantages of 64-bit Computing

A 32-bit processor can handle a 32-bit integer, and a 64-bit processor can handle a 64-bit integer. A 64-bit processor can therefore handle a larger range of integer values. Since memory addresses are integers that specify a location in memory, a processor that can handle more integer values can also handle more memory addresses. (Each byte of memory in a computer must have a unique address so that applications can keep track of and identify the memory.)

On 32-bit machines, memory addresses are 32 bits in length and stored as base-2 numbers. (The base-2, or "binary," number system expresses integer values as combinations of two digits: 0 and 1.) There are approximately 4 billion possible different 32-bit binary numbers (232), which accounts for the 4 GB memory address space limit on machines with a 32-bit processor.

By contrast, a 64-bit processor can theoretically address up to 16 exabytes (EB) (264 bytes) of memory, giving access therefore to practically unlimited memory.

64-bit memory addressing enables applications to store large data sets entirely in memory. This eliminates the performance penalty associated with swapping portions of the data in and out to disk. For example, the increased memory space available on a 64-bit platform enables large databases to be preloaded into memory, improving data access times for database client applications. Memory is accessed hundreds of times faster than disk drives, so replacing I/O access to data with access via memory is extremely beneficial for database performance. Because more database operations can run at memory speed rather than disk speed, 64-bit machines enable databases to scale to support more users.

On 32-bit systems, memory management extensions exist that enable applications to use more than 4 GB of memory. These extensions are Physical Address Extension (PAE) and the Microsoft Windows-only feature Address Windowing Extension (AWE). Databases such as Oracle and SQL Server can take advantage of PAE and AWE to gain access to additional memory beyond their 4 GB limit. One constraint with PAE and AWE, however, is that memory above 4 GB can only be used to store data, it cannot be used to store or execute code. So, for example, the memory is not available to other memory consuming database operations such as caching query plans, sorting, indexing, joins, or for storing user connection information. By contrast, 64-bit machines make memory available to all database processes and operations.

Other memory intensive applications that benefit from running on a 64-bit platform include computer-aided design/computer-aided manufacturing (CAD/CAM), scientific modelling and other engineering applications. These applications usually perform optimally by holding large amounts of data in memory. Graphics programs will also see performance improvements as they, too, often deal with large amounts of data, especially when rendering 3-D imagery.

In addition, some types of data processing work more efficiently in a 64-bit environment, such as encryption. Most encryption algorithms are based on very large integers—the larger the integers, the more secure the encryption. Encryption applications can take advantage of 64-bit integers and gain a consequent performance boost on 64-bit systems.

For applications that do not need to address memory beyond the 32-bit processor limit of 4 GB, 64-bit machines still provide substantial benefits in terms of processing speed. With a 64-bit processor, each general-purpose register is 64-bits wide and can represent a much larger integer. (A register is high-speed memory within a processor that provides the fastest way for a processor to access data. A general-purpose register is available for any use rather than being reserved for a specific purpose by the processor or operating system.) Programming languages such as C and C++ can perform mathematical operations on 64-bit integers. 64-bit integer types can be contained within a single register on a 64-bit machine (as opposed to a 32-bit machine, where 64-bit numbers have to be split across two 32-bit registers). The register-width difference produces a substantial reduction in resource requirements when performing 64-bit mathematics. Mathematical operations on 64-bit numbers consume fewer registers and require fewer processor instructions on a 64-bit machine than on a 32-bit machine.

Improvements in parallel processing and bus architectures, enable 64-bit machines to support a larger number of processors (up to 64). An increased capacity for processor support means that a single machine has the potential to support more processes, applications, and users.

On Solaris machines, 32-bit applications using standard I/O are limited to 256 file descriptors, which limits the number of open files that the application can maintain. (A file descriptor is an integer used to identify an open file for the purpose of file access.) This limit is present because Solaris machines use a char type to represent the file descriptors, which can only hold a range values of 0–255. If there are no free file descriptors in the 0-255 range, an I/O error results if the application attempts to open another file. The limit is not applicable to 64-bit applications, which can use up to 2 billion descriptors.

64-bit Unix and Linux Platforms

There are several 64-bit Unix and Linux Platforms, and these based around different 64-bit processors. For example, Easysoft ODBC drivers are available on the following 64-bit Unix and Linux platform/processor combinations:

PlatformProcessor
AIXPPC (PowerPC)
HP-UXItanium i64
HP-UXPA-Risc 2 (Precision Architecture-Reduced Instruction Set Computing)
IrixMIPS (Microprocessor without Interlocked Pipeline Stages)
Linuxx86-64
LinuxItanium i64
SolarisSPARC (Scalable Processor Architecture)
Tru64 UNIXAlpha

64-bit operating systems are able to run both 32-bit and 64-bit applications concurrently. To execute correctly, each application requires a number of libraries. However, the file names for the 32-bit and 64-bit versions of these libraries are identical. They must be differentiated from each other in another way. The most common approach is to use separate directories for 32-bit and 64-bit libraries, although the naming convention used for the directory structure differs from system to system.

Linux systems that follow the Filesystem Hierarchy Standard (FHS) place 64-bit libraries in /lib64 and /usr/lib64. 32-bit libraries remain in /lib and /usr/lib. Using lib for 32-bit libraries enables 32-bit programs to work on 64-bit machines without any changes. Linux distributions that follow the FHS requirements for 32-bit/64-bit library locations include Fedora, RedHat and SUSE. For example, on this FHS-conformant Fedora system, the 64-bit version of the GNU C library is located in /lib64. The 32-version is located in /lib. The file name is the same for both 64-bit and 32-bit versions. They are separated by their location.

$ file /lib64/libc-2.7.so
/lib64/libc-2.7.so: ELF 64-bit LSB shared object, x86-64, version 1
(SYSV), for GNU/Linux 2.6.9, not stripped
$ file /lib/libc-2.7.so
/lib/libc-2.7.so: ELF 32-bit LSB shared object, Intel 80386, version 1
(SYSV), for GNU/Linux 2.6.9, not stripped

Solaris and HP-UX (PA-Risc) systems use a similar method to separate 32-bit and 64-bit libraries. However, although these operating systems preserve the existing 32-bit library directory structure, they use a proprietary naming convention for the 64-bit library directory. Solaris uses /usr/lib/sparcv9 (or /usr/lib/64) for 64-bit libraries and /usr/lib for 32-bit libraries. HP-UX (PA-Risc) uses /usr/lib/pa20_64 for 64-bit libraries and /usr/lib for 32-bit libraries.

HP-UX (Itanium) systems use /usr/lib/hpux32 to store 32-bit libraries and /usr/lib/hpux64 to store 64-bit libraries. (PA-Risc based libraries are also present on Itanium HP-UX systems, in the standard locations, /usr/lib and /usr/lib/pa20_64.)

Itanium 2 based Linux systems can provide 32-bit support through the Intel Architecture 32-bit Execution Layer (IA-32 EL). IA-32 EL is a software package that translates IA-32 instructions into Itanium instructions. IA-32 EL replaces the less efficient, hardware-based 32-bit support of the original Itanium processor. Linux distributions that support IA-32 EL include Red Hat Enterprise Linux and SUSE Linux Enterprise Server. The directory structure for 32-bit libraries installed under IA-32 EL is /emul/ia32-linux/lib and /emul/ia32-linux/usr/lib. 64-bit libraries are installed in /lib and /usr/lib.

On AIX systems, most system libraries are hybrid mode archives—a single library archive file that contains both 32-bit and 64-bit versions of its member objects. AIX uses a "_64" file name suffix to separate the 64-bit objects from the 32-bit objects. The name of the 32-bit object remains unchanged. The following command illustrates this naming convention. It lists both 32-bit and 64-bit object modules contained in the standard C library, libc.a:

$ ar -X 32_64 -t /usr/lib/libc.a
frexp.o
itrunc.o
ldexp.o
.
.
.
frexp_64.o
itrunc_64.o
ldexp_64.o
.
.
.

64-bit Windows Platforms

64-bit Windows is available for systems based on these processor platforms:

For example, there are x64 editions of Microsoft Windows Vista, Microsoft Windows Server 2003 and Microsoft Windows XP; there are Itanium editions of Windows Server 2003 and Microsoft Windows Server 2008.

64-bit Windows platforms support both 32-bit and 64-bit applications. On 64-bit Microsoft Windows platforms, 32-bit applications run in the Windows-on-Windows (WOW64) subsytem. WOW64 emulates the 32-bit Windows Operating System to allow 32-bit applications to run without modification.

A limitation of WOW64 is that 32-bit processes cannot load a 64-bit dynamic-link libraries (DLLs) and 64-bit processes cannot load a 32-bit DLLs. As the Windows system directory contains both the installed applications and their DLLs, it must be separated into a native system directory for 64-bit applications (%windir%\system32) and a WOW64 directory for the 32-bit applications (%windir%\syswow64). To enable 32-bit applications to transparently access the WOW64 system directory, the WOW64 layer provides a file system redirector. Attempts to access the %windir%\system32 directory by a WOW64 process are redirected to the %windir%\syswow64 directory.

The Itanium-based versions of Windows Server 2003 (SP1) and Windows XP use IA-32 EL to support 32-bit applications. IA-32 EL translates processor instructions between the 32-bit and 64-bit instruction sets and cooperates with the WOW64 subsystem to run 32-bit applications.

64-bit Mac OS X Platforms

Starting with version 10.4 (Tiger), Mac OS X supports command-line 64-bit executables on PowerPC G5 and Intel 64 (Xeon, Core 2 Duo and Core i3/i5/i7) Macintosh computers. Version 10.4 includes both 32-bit and 64-bit versions of the libSystem library and the Accelerate framework. Other system frameworks, libraries and plug-ins are 32-bit only. libSystem provides the standard C runtime environment, input/output routines, maths libraries and other functionality required by command-line applications and network services. libSystem does not provide any functionality to allow an application to implement a graphical user interface (GUI). Any application that links with a GUI library is 32-bit on version 10.4.

Starting with version 10.5 (Leopard), Mac OS X supports 64-bit GUI applications on PowerPC G5 and Intel 64 Macintosh computers. Version 10.5 supports 64-bit Cocoa/Objective C applications. Cocoa is object-oriented application programming interface (API), which provides an integrated set of shared object libraries, a runtime system and a development environment. The native language for Cocoa is Objective-C, which provides object-oriented extensions to standard C and Objective-C++. Carbon, a collection of C programming interfaces, is not supported for 64-bit applications. Two 64-bit GUI applications shipped with version 10.5: Xcode (Apple’s graphical integrated development environment, which is an optional install) and Chess.

Starting with version 10.6 (Snow Leopard), Mac OS X uses a 64-bit kernel (K64) on some Intel 64 Macintosh computers. Version 10.6 shipped with four 32-bit GUI applications: iTunes, Grapher, Front Row, and DVD Player. All other GUI applications were 64-bit.

On Mac OS X, a "64-bit capable" application is one that can be opened in 64-bit mode as well as 32-bit mode. To find out whether a GUI application is 64-bit capable, select the application icon, and then choose File > Get Info. If the application is 64-bit capable, an Open in 32-bit mode option will be present. If Open in 32-bit mode is not present, the application is not 64-bit capable and can only run in 32-bit mode.

On an Intel 64 Macintosh computer, running this command in a Terminal window lists the programs on the computer that can run in 64-bit mode:

locate -0 app/Contents/MacOS/ | xargs -0 file | grep x86_64

On a PowerPC G5 Macintosh computer, use this command instead:

locate -0 app/Contents/MacOS/ | xargs -0 file | grep ppc64

The package file for a 64-bit capable application, contains two versions of the application: a 32-bit and a 64-bit version. To do this, the universal binary format is used, which is the same file format that enables a PowerPC and Intel version of an application to be embedded in single application package.

If an application is run in 64-bit mode, all supporting binaries needed to run the application, including frameworks, libraries, and plug-ins, must be 64-bit capable. If an application is run in 32-bit mode, all supporting binaries must be 32-bit.

Mac OS X allows a 32-bit kernel to run 64-bit applications. Version 10.6+ runs 64-bit capable applications in 64-bit mode regardless of whether it’s booting into a 64-bit or 32-bit kernel. The main advantage of booting into a 64-bit kernel is the ability to use more that 32 gigabytes (GB) of RAM.

When booted into a 32-bit kernel, Mac OS X is in "32-bit mode". When booted into a 64-bit kernel, Mac OS X is in "64-bit mode". Initially, the default mode for version 10.6 was 32-bit mode, to enable greater backwards compatibility with existing 32-bit hardware and software. In mid-2010, this was changed so that the default mode for some Macintosh computers (for example, Mac Pros) became 64-bit mode.

64-bit Data Models

A data model specifies the size of data types imposed by the underlying architecture. It is usually implemented by the operating systems so that multiple data models can be used on the same processor.

In the 32-bit data model (known as the ILP32 model), int, long and pointer (the ILP part of the acronym) data types are 32 bits in length. Because ILP32 lacks 64-bit pointers, the model is inappropriate for use with 64-bit processors, which are able to address large amounts of memory (beyond the 4 GB ceiling imposed by 32-bit systems). By contrast, 64-bit data models provide 64-bit pointers to take advantage of the larger address space provided by 64-bit processors.

The 32-bit (ILP32) and 64-bit (LP64, LLP64, ILP64) data models are shown in the following table. The table shows the size of the data types in bits.

Data typesILP32LP64LLP64ILP64
char8888
short16161616
int32---32
int32323264
long32643264
long long (int64)--64-
pointer32646464

The difference between the three 64-bit models (LP64, LLP64 and ILP64) lies in the non-pointer data types. With two of the three 64-bit data models (LP64 and LLP64), it is no longer valid to assume that int, long and pointers data types are the same size. Applications whose code makes this assumption often cease to work properly when compiled on a 64-bit platform.

LP64 is the standard data model on 64-bit Linux, Unix and Mac OS X systems. In the LP64 model, longs and pointers are 64 bits wide and ints remain fixed at 32 bits. The advantage of this data model is that it provides 64-bit addressing (64-bit pointers), 64-bit arithmetic (64-bit longs), backward compatibility (most ints in existing applications can remain as 32 bits in a 64-bit environment) and portability (does not require new data types such as int32 and int64). The difference in the size of long and pointer between ILP32 and LP64 can cause data truncation issues in code that assumes these types are the same width as ints.

LLP64 is the standard data model on 64-bit Windows systems, and is sometimes described as a 32-bit model with 64-bit addresses. In the LLP64 model, pointers are 64 bit; the other types remain unchanged from the ILP32 model. int or long variables that need to be 64 bits in length are changed to long long (also know as int64), a non-standard data type introduced by the LLP64 model.

ILP64 preserves the relationship between the three basic types that ILP32 developers are used to by making int, long and pointer types the same size. Converting or assigning pointers to int or long does not result in data truncation. The disadvantage of the ILP64 data model is that it depends on a new data type (int32) for 32-bit ints. This makes it difficult to write code that can run on both 32-bit and 64-bit platforms without resorting to conditional compilation.

ODBC on 64-bit Platforms

Background

In the original ODBC API specification and header files, the SQLINTEGER and SQLUINTEGER types, used for passing and returning data buffer lengths, were 32-bit values. In the underlying data model, ILP32, these types are 32-bit longs. Microsoft subsequently introduced two new types for data buffer arguments, SQLLEN and SQLULEN, and changed some ODBC APIs to use the new types. In version 3.52 of the ODBC specification, Microsoft changed the SQLLEN and SQLULEN types for 64-bit Windows platforms. On 64-bit Windows, the SQLLEN and SQLULEN types were changed from longs to long longs. Even though longs are 32-bit in the 64-bit Windows data model, long longs are 64-bit.

On 64-bit Windows, pointers are 64-bit, which gives 64-bit ODBC applications the potential to take advantage of 64-bit memory addressing. For example, an application could use 64-bit addressing to provide a large buffer for LOB data. A 32-bit value may not be sufficient to return the length of data in a large buffer on 64-bit platforms. This may be the reason why Microsoft chose to increase the size of the SQLLEN and SQLULEN types from 32-bit longs to 64-bit long longs.

ODBC on 64-bit Linux and Unix Platforms

unixODBC Driver Manager

It is possible to build the unixODBC ODBC driver manager on 64-bit platforms with either 32-bit or 64-bit SQLLEN/SQLULEN types.

unixODBC 2.2.13+

In unixODBC 2.2.13, the default size of SQLLEN/SQLULEN types changed from 32 bits to 64 bits. In unixODBC 2.2.13+, the BUILD_LEGACY_64_BIT_MODE macro in sqltypes.h controls whether SQLLEN/SQLULEN types are 32-bit or 64-bit (the default). To build unixODBC 2.2.13+ with 32-bit SQLLEN/SQLULEN types, use CFLAGS to define BUILD_LEGACY_64_BIT_MODE before configuring the unixODBC build system. For example:

$ CFLAGS=-DBUILD_LEGACY_64_BIT_MODE=1
$ export CFLAGS
$ ./configure --enable-gui=no --enable-drivers=no
$ make
$ cd exe
$ ./odbc_config --ulen
-DSIZEOF_SQLULEN=4
$ ./odbc_config --cflags
-DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG \
   -DSIZEOF_LONG_INT=4 -I/home/myuser/include

(The unixODBC source distribution is available to download from the unixODBC web site, ftp://ftp.unixodbc.org/pub/unixODBC.)

If your application includes sqltypes.h and you want to use it with a unixODBC 2.2.13+ Driver Manager that is built with 32-bit SQLLEN/SQLULEN types, you need to build the application with the same define as the one used when building unixODBC. Alternatively, include the file unixodbc_conf.h.

You can use unixODBC’s odbc_config program to display information about how unixODBC was built. The unixODBC 2.2.13+ version of odbc_config supports the --ulen option, which reports whether the unixODBC driver manager was built with 64-bit or 32-bit SQLLEN/SQLULEN types. If odbc_config --ulen displays -DSIZEOF_SQLULEN=8, unixODBC was built with 64-bit SQLLEN/SQLULEN types. If odbc_config --ulen displays -DSIZEOF_SQLULEN=4, unixODBC was built with 32-bit SQLLEN/SQLULEN types.

Note that not all unixODBC distributions include odbc_config. Note also that odbc_config only reports information about the unixODBC distribution it was shipped with. For example, you have two copies of unixODBC installed on a machine: one copy built from source, which includes odbc_config; one copy supplied with the operating system, which does not include odbc_config. The odbc_config program cannot be used to provide information about the operating system version of unixODBC.

In unixODBC 2.3+, the odbcinst program can be used to report whether the unixODBC driver manager was built with 64-bit or 32-bit SQLLEN/SQLULEN types. In the example output, the driver manager that was installed by an Easysoft ODBC driver was built with 32-bit SQLLEN/SQLULEN types:

$ cd /usr/local/easysoft/unixODBC/bin
$ ./odbcinst -j
unixODBC 2.3.0
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/myuser/.odbc.ini
SQLULEN Size.......: 4
SQLLEN Size........: 4
SQLSETPOSIROW Size.: 2

Note If your version of unixODBC was built with 32-bit SQLLEN/SQLULEN types, you need to use it with an ODBC driver that has been built with 32-bit SQLLEN/SQLULEN types. If your version of unixODBC was built with 64-bit SQLLEN/SQLULEN types, you need to use it with an ODBC driver that has been built with 64-bit SQLLEN/SQLULEN types. (See How do I know whether my Linux/UNIX ODBC driver is the 64-bit or 32-bit SQLLEN/SQLULEN version?.) If you are using or want to use an Easysoft ODBC driver with an existing version of unixODBC (i.e. a version that is not included in the Easysoft driver distribution), see How do I know whether my Linux/UNIX ODBC driver is the 64-bit or 32-bit SQLLEN/SQLULEN version? and How do I obtain a 64-bit or 32-bit SQLLEN/SQLULEN Easysoft ODBC driver for Linux/UNIX platforms?.

unixODBC 2.2.12

The default behaviour for unixODBC 2.2.12 is to build the driver manager with 32-bit SQLLEN/SQLULEN types. The BUILD_REAL_64_BIT_MODE and SIZEOF_LONG macros in unixodbc_dist_dir/include/sqltypes.h determine whether these types are 32-bit (the default) or 64-bit. To build unixODBC 2.2.12 with 64-bit SQLLEN/SQLULEN types:

  1. Download the unixODBC distribution, unpack and cd into the directory created by unpacking the distribution file:
    $ gunzip unixODBC-2.2.12.tar.gz
    $ tar -xvf unixODBC-2.2.12.tar
    $ cd unixODBC-2.2.12
  2. Use the CPPFLAGS environment variable to define BUILD_REAL_64_BIT_MODE and set SIZEOF_LONG to 8:
    $ CPPFLAGS="-DBUILD_REAL_64_BIT_MODE -DSIZEOF_LONG=8"
    $ export CPPFLAGS
  3. Configure the unixODBC build system. For example:
    $ ./configure --enable-gui=no --enable-drivers=no

    For information about unixODBC configure options, see our Linux/UNIX ODBC article. In the example command, the options specify that unixODBC should be built without GUI components or sample ODBC drivers.

The default for the unixODBC 2.2.12 source distribution is to build 32-bit SQLLEN/SQLULEN types. However, this does not mean that a unixODBC 2.2.12 package included with a Linux or Unix distribution will be built with 32-bit SQLLEN/SQLULEN types too. For example, on RedHat, Debian and Ubuntu Linux distributions, the unixODBC package is built with 64-bit SQLLEN/SQLULEN types.

Applications that pass 64-bit values to SQLLEN/SQLULEN ODBC API parameters must be used with a version of unixODBC that is built with 64-bit SQLLEN/SQLULEN types (and vice versa). If unixODBC is built with 64-bit SQLLEN/SQLULEN types, it must be used with an ODBC driver that is built with 64-bit SQLLEN/SQLULEN types (and vice versa). If you are using a version of unixODBC that was included in an Easysoft ODBC driver distribution, both ODBC driver manager and ODBC driver will be built with the same size SQLLEN/SQLULEN types. However, the Easysoft driver installation script gives you the option to use the version of unixODBC included in the operating system distribution rather than the driver distribution. If an Easysoft ODBC driver built with 32-bit SQLLEN/SQLULEN types was used with a unixODBC driver manager built with SQLLEN/SQLULEN types, the results will be unpredictable. Side effects could include data loss/corruption or your application crashing.

For example, Oracle DG4ODBC passes 64-bit values to SQLLEN/SQLULEN ODBC API parameters, and therefore must be used with a 64-bit SQLLEN/SQLULEN ODBC driver manager and ODBC driver. To illustrate the potential side effects of not doing this, we used the following application/driver manager/driver combinations to retrieve NVARCHAR SQL Server data from the Northwind Suppliers table:

In both cases, we experienced data loss:

SQL> select "ContactName" from Suppliers@sqlsrv2005;

ContactName
------------------------------------------------------------
Charlotte Cooper
Shelley Burke
Regina Murphy
Yoshi Nagas
Antonio del V
Mayumi Ohno
Ian Devling
Peter Wilson
Lars Peterson
Carlos Diaz
Petra Winkler

ContactName
------------------------------------------------------------
Martin Bein
Sven Petersen
Elio Rossi
Beate Vileid








ContactName
------------------------------------------------------------








29 rows selected.

At the time of writing, applications that Easysoft know to have been built with 64-bit SQLLEN/SQLULEN types are:

iODBC Driver Manager

iODBC is another ODBC driver manager that is available for Linux and Unix platforms (and Mac OS X and Windows). The default for the iODBC source distribution is to build the iODBC driver manager with 64-bit SQLLEN/SQLULEN types. These types were introduced in the 3.52.1 release of iODBC.

ODBC on 64-bit Windows Platforms

On 64-bit Windows platforms, there is both a 32-bit and 64-bit version of the Microsoft ODBC Driver Manager. The 64-bit version (%windir%\System32\Odbc32.dll):

The 32-bit version of the Driver Manager (%windir%\SysWOW64\Odbc32.dll):

The Driver Manager implements the SQLDrivers and SQLDataSources APIs to allow an application to find out what ODBC drivers are installed and what ODBC data sources are defined. The SQLDrivers API provided by the 64-bit Microsoft ODBC Driver Manager only lists 64-bit ODBC drivers and vice versa. The SQLDataSources API provided by the 64-bit Microsoft ODBC Driver Manager does not list 32-bit system data sources and vice versa.

On 64-bit Windows platforms, there is both a 32-bit and a 64-bit version of ODBC Administrator, the application you use to manage ODBC data sources. The 64-bit ODBC Administrator is located in the standard location: Administrative tools in Control Panel. To run the 32-bit version of the ODBC Administrator, in the Windows Run dialog box, type:

%windir%\syswow64\odbcad32.exe

The 64-bit version of ODBC Administrator enables you to:

The 32-bit version of ODBC Administrator enables you to do these tasks for 32-bit ODBC drivers and applications.

A system ODBC data source is visible to all users on the computer on which it has been defined. On 64-bit Windows platforms, system data sources for 64-bit ODBC drivers are stored in a Registry key called HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI; system data sources for 32-bit ODBC drivers are stored in a Registry key called HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI. 64-bit system ODBC data sources are only visible to 64-bit applications. 32-bit system ODBC data sources are only visible to 32-bit applications. The WOW64 registry redirector intercepts calls made to certain portions of the registry and redirects them to another portion of the registry. Registry redirection affects the HKEY_LOCAL_MACHINE\SOFTWARE key. Registry calls made to this key by 32-bit applications are redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. So, for example, when a 32-bit application calls SQLDataSources, the resultant registry call is redirected from HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI, and the only system data sources that are returned are ones for 32-bit ODBC drivers.

The 32-bit Microsoft ODBC Driver Manager will not attempt to load an ODBC driver specified by a 64-bit system data source. If a 32-bit application attempts to connect to a 64-bit system data source, the connection fails with the error:

[Microsoft][ODBC Driver Manager]
The specified DSN contains an architecture mismatch between the Driver and Application

This error occurs irrespective of whether there is also 32-bit version of the ODBC driver specified in data source installed on the computer.

The 64-bit Microsoft ODBC Driver Manager will not attempt to load an ODBC driver specified by a 32-bit system data source. If a 64-bit application attempts to connect to a 32-bit system data source, the connection also fails with the "architecture mismatch" error.

A user data source is only visible to the user who created it. On 64-bit Windows platforms, user data sources for both 32-bit and 64-bit ODBC drivers are stored in a Registry key called HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI. The registry redirector does not affect this key. User data sources are visible to all ODBC-enabled applications therefore, irrespective of application or driver architecture. For example, the 32-bit and 64-bit versions of ODBC Administrator list user data sources for both 32-bit and 64-bit ODBC drivers. (To avoid confusion, you can indicate the driver architecture in the data source name, for example, by suffixing the name with "_32" or "_64".)

If a 32-bit application attempts to connect to a valid user data source for a 64-bit ODBC driver, the connection will succeed if a 32-bit version of the driver is installed. Otherwise, the connection will fail with the "architecture mismatch" error. For example, Microsoft’s SQL Server ODBC driver installs both a 64-bit library (%WINDIR%\System32\sqlsrv32.dll) and a 32-bit library (%WINDIR%\SysWOW64\sqlsrv32.dll) on 64-bit Windows platforms. If a 32-bit application attempts to connect to a valid user data source for the 64-bit version of the SQL Server ODBC driver, the connection will succeed. This is because the WOW64 file system redirector loads the 32-bit version of the ODBC driver (in %windir%\SysWOW64) rather than the 64-bit driver (in %windir%\System32) specified by the data source.

Similarly, if a 64-bit application attempts to connect to a valid user data source for a 32-bit ODBC driver, the connection will succeed if a 64-bit version of the driver is installed.

As mentioned, on 64-bit Windows, some ODBC drivers install both a 32-bit and a 64-bit version of the driver. For example, Microsoft’s SQL Server and SQL Server Native Client ODBC drivers; Easysoft’s Firebird, InterBase and ODBC-ODBC Bridge drivers. These ODBC drivers can be used with both 32-bit and 64-bit ODBC applications therefore.

On 64-bit Windows, some ODBC drivers are only available as a 64-bit library. For example, Microsoft’s ACE-based Access ODBC Driver (*.mdb, *.accdb). Some ODBC drivers are only available as a 32-bit library irrespective of the operating system platform. For example, Microsoft’s Jet-based Access ODBC Driver (*.mdb). (Note that if you attempt to connect a 64-bit application to User data source for the Jet-based Access ODBC Driver, the 64-bit ACE-based driver is not transparently loaded. Although both are capable of connecting to an MDB format Access database, they are different drivers with a different file name.)

If an ODBC driver is specified on the connection string, the driver architecture must be the same as the application’s. Otherwise, the connection will fail with the error:

[Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified (SQL-IM002)

For example, the preceding error will be returned if a 64-bit application uses a DSN-less connection to connect to Microsoft’s Jet-based Access ODBC driver:

DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\Users\Public\Downloads\Northwind.mdb;

Windows 8

Starting in Windows 8, both the 32-bit and 64-bit version of the ODBC Administrator are located in Administrative tools in Control Panel. The icons for the two versions are labelled:

The User DSN and System DSN tabs in the ODBC Administrator include a Platform column, which tells you whether a data source can be used with a 32-bit or a 64-bit application or both.

Both versions of the ODBC Administrator list all installed drivers and available data sources regardless of the driver architecture. If the driver architecture is different to that of the ODBC Administrator, you cannot use the tool to create, edit or remove a data source for that driver. For example, to create a System data source for the 32-bit only Microsoft Access ODBC driver, you need to use the 32-bit ODBC Administrator. This data source will be visible in the 64-bit ODBC Administrator but not editable or removable.

Windows PowerShell Cmdlets for ODBC

Windows PowerShell is a command-line/scripting environment from Microsoft. Built-in Windows PowerShell commands, called cmdlets, enable users to control and automate the administration of the Windows operating system and applications that run on Windows.

Starting in Windows 8, a number of PowerShell cmdlets are provided for listing and managing ODBC drivers and data sources. For example, the Add-OdbcDsn cmdlet enables an ODBC data source to be added. This sample cmdlet adds a 64-bit System ODBC data source for Easysoft's Derby ODBC driver:

PS C:\> Import-Module Wdac
PS C:\> Add-OdbcDsn "64-bit Derby System DSN" -DriverName "Easysoft ODBC-Derby"
                                              -DsnType System -Platform 64-bit
                                              -SetPropertyValue @("Database=nativedb")
                                              -PassThru

Some ODBC cmdlets have a -Platform parameter, which lets you set the target architecture for the cmdlet.

When listing ODBC drivers (Get-OdbcDriver) or data sources (Get-OdbcDsn), -Platform can be set to 32-bit, 64-bit or All. The default value for -Platform is All, and so both 32-bit and 64-bit ODBC drivers and data sources are listed.

When managing ODBC drivers (Set-OdbcDriver) or data sources (Add-OdbcDsn, Remove-OdbcDsn, Set-OdbcDsn) -Platform can be set to 32-bit or 64-bit. By default, -Platform matches the architecture of the process in which the cmdlet is being run. For example, if you start a 32-bit PowerShell session by running the icon labelled Windows PowerShell (x86) (which runs a PowerShell executable located in the WOW64 directory), and omit Platform when adding a data source, your data source will be 32-bit. (Note that you can add 64-bit ODBC data sources or configure 64-bit ODBC drivers from a 32-bit PowerShell process and vice versa.)

ODBCConf

ODBCConf is a Windows command line utility that enables you to install and configure ODBC drivers and configure ODBC data sources.

On 64-bit Windows platforms, there is both a 32-bit and 64-bit version of ODBCConf.

The 32-bit version of the ODBCConf executable (odbcconf.exe) is located in this folder:

%windir%\SysWOW64

The 64-bit version of the ODBCConf executable is located in folder:

%windir%\System32

If you want to install or configure a 32-bit ODBC driver or configure a data source for a 32-bit ODBC driver, use the 32-bit version of ODBCConf.

If you want to install or configure a 64-bit ODBC driver or configure a data source for a 64-bit ODBC driver, use the 64-bit version of ODBCConf.

Accessing Oracle from 32-bit ODBC Applications on 64-bit Windows Platforms

The Easysoft ODBC-Oracle Driver accesses Oracle by using the Oracle database client, which uses Oracle Net to communicate with the database. Some versions of the Oracle Net software fail with the error ORA-12154: TNS:could not resolve the connect identifier specified if the application with which you are trying to connect is installed in a directory that contains parentheses in its name. This issue affects 32-bit applications on 64-bit Windows platforms because Windows installs 32-bit applications under the drive:\Program Files(x86) directory.

The Oracle bug report associated with this problem is Bug 3807408 Cannot Externally Authenticate User With Quote In Username (Oracle MetaLink login required).

To fix this problem and therefore enable 32-bit applications to access Oracle through ODBC/Oracle Net, obtain and apply an Oracle patch set from that contains a fix for bug 3807408.

If the patch is not available for your version of the Oracle client, you can try working around the problem by starting your application from the command prompt. In the command line, replace Program Files(x86); with Progra~2.

For more information about Oracle on 64-bit Windows issues and workarounds, see the MSDN forum posting Connecting to Oracle on 64-bit (x64) machines.

ODBC on 64-bit Mac OS X Platforms

Starting with version 10.2 (Jaguar), the iODBC Driver Manager is included with Mac OS X. Source code for each version of iODBC that Apple has shipped with the operating system (starting with Mac OS X 10.3) is available on the Apple Open Source web site. (To access the relevant iODBC web page, choose your version of Mac OS X from the Releases list.)

The iODBC Driver Manager package includes:

Apple also provide ODBC Administrator (Applications > Utilities > ODBC Administrator), a GUI application for managing ODBC data sources. ODBC Administrator lets you:

Note Starting with Mac OS X version 10.6 (Snow Leopard), ODBC Administrator is no longer shipped with the operating system and must be downloaded and installed separately. ODBC Administrator is available to download from the Apple Support web site as a Disk Image file (.dmg).

Mac OS X packages containing more recent versions of iODBC than the one provided by Apple can be downloaded from the iODBC web site:

If you want to run an ODBC application in 64-bit mode, the ODBC Driver Manager it is linked with must be 64-bit capable. In 64-bit mode, the ODBC Driver Manager can only load a 64-bit capable ODBC driver. Similarly, if you want to run an ODBC application in 32-bit mode, the ODBC Driver Manager it is linked with must be 32-bit capable. In 32-bit mode, the ODBC Driver Manager can only load a 32-bit capable ODBC driver.

On the Macintosh computer we used during testing for this article (Mac OS X 10.7.2), the iODBC Driver Manager we installed from either of the SDKs mentioned earlier in this section supported both 32-bit and 64-bit architectures.

To find out which architectures your ODBC driver supports, use the file command. In a Terminal window, run:

file driver

where driver is the full path to the ODBC driver binary. On Intel 64 Macintosh computers, the file command output will contain "x86_64" if the ODBC driver binary contains a 64-bit driver. If the ODBC driver binary, contains a 32-bit driver, the file command output will contain "i386". For example, Easysoft’s SQL Server ODBC driver, is a universal binary that contains both a 32-bit and a 64-bit driver:

cd /usr/local/easysoft/sqlserver/lib
file libessqlsrv.so
libessqlsrv.so is a Mach-O universal binary with 2 architectures i386 / x86_64

On PowerPC G5 Macintosh computers, the file command output will contain "ppc64" if a 64-bit version of an ODBC driver is present in the ODBC driver binary and "ppc7400" if a 32-bit version is present.

If your application and ODBC driver architectures are different, your connection will fail. For example, the following connection fails because the application can only run in 32-bit mode and the ODBC driver can only run in 64-bit mode:

$ cd /Library/Application\ Support/iODBC/bin
$ file ./iodbctest
./iodbctest: Mach-O universal binary with 2 architectures
./iodbctest (for architecture ppc7400):	Mach-O executable ppc
./iodbctest (for architecture i386):	Mach-O executable i386
$ file /usr/local/lib/myodbcdriver.so 
/usr/local/lib/myodbcdriver.so: Mach-O 64-bit bundle x86_64
$ ./iodbctest "DSN=myodbcdriverdsn;UID=sa;PWD=p455w0rd"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0709.0909
1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/usr/local/lib/myodbcdriver.so, 6): no suitable image found.  Did find:
	/usr/local/lib/myodbcdriver.so: mach-o, but wrong architecture (0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003

Frequently Asked Questions

Do I need to use a 32-bit or 64-bit ODBC driver?

Whether you use a 32-bit or 64-bit ODBC driver depends on whether your application is 32-bit or 64-bit. A 64-bit ODBC driver can only be used with a 64-bit application. Similarly, a 32-bit ODBC driver can only be used with a 32-bit application.

64-bit applications must be linked against 64-bit libraries (known as shared objects on Unix and DLLs on Windows). For this reason, 64-bit applications can only link against a 64-bit ODBC Driver Manager shared object (or DLL). 64-bit ODBC Driver Managers can only load 64-ODBC drivers.

For the same reason, a 32-bit ODBC driver can only be used with a 32-bit application.

Note that it does not matter whether the database you are connecting to is 32-bit or 64-bit. Your choice of ODBC driver is dictated by the architecture of the client application not the database.

Examples

To connectUse
A 64-bit version of IBM UniVerse/UniData to a SQL Server database.A 64-bit SQL Server ODBC driver.
A 32-bit version of Oracle HS ODBC on a 64-bit platform to a SQL Server database.A 32-bit SQL Server ODBC driver.

32-bit ODBC drivers function perfectly well on 64-bit systems.

A 32-bit version of Python to a 64-bit Oracle database.A 32-bit Oracle ODBC driver.
A 64-bit version of PHP to an Access database running on a 64-bit Windows machine.A 64-bit ODBC-ODBC Bridge client and a 32-bit ODBC-ODBC Bridge server.

How can I tell whether an application is 32-bit or 64-bit?

Because 32-bit and 64-bit applications can coexist on a 64-bit system, knowing whether your application platform architecture is 64-bit is not enough to determine whether an application is 64-bit or 32-bit. For example, IBM support Lotus Domino 7.x on 64-bit AIX, Solaris, Linux and Windows 2003 machines, even though Domino 7.x is a 32-bit application.

Similarly, just because your application was included in a 64-bit distribution does not necessarily mean that it is also 64-bit. For example, the HSODBC component included in 64-bit Oracle distributions is 32-bit.

On Unix systems, you can use the file command to tell whether an application is 32-bit or 64-bit. To do this, locate the application binary and then run file file. If the file is 64-bit, the command output will contain "ELF 64-bit" (or something similar such as "ELF-Class64" or "ELF-64"). If the file is 32-bit, the command output will contain "ELF 32-bit".

(To check whether Lotus Domino is 64-bit, you can also type sh stat server at the server console. The "Server.Version.Architecture" statistic shows you whether Domino is 64-bit.)

In this example, the file command’s output shows that PHP’s command line interface binary is 64-bit:

$ which php
/usr/bin/php
$ file /usr/bin/php
/usr/bin/php: ELF 64-bit LSB executable, x86-64, version 1
(SYSV), dynamically linked (uses shared libs),
for GNU/Linux 2.6.9, stripped

This application, therefore, needs to be used with a 64-bit ODBC Driver Manager/driver, which can also be verified with the file command. The unixODBC Driver Manager shared object is called libodbc.so. You can find out the name of the ODBC driver shared object by checking the entry for the driver in /etc/odbcinst.ini. Look at the Driver attribute value.

For example:

$ locate libodbc.so
/usr/local/easysoft/unixODBC/lib/libodbc.so
/usr/local/easysoft/unixODBC/lib/libodbc.so.1
/usr/local/lib/libodbc.so
/usr/local/lib/libodbc.so.1
$ file /usr/local/lib/libodbc.so
/usr/local/lib/libodbc.so: symbolic link to `libodbc.so.1.0.0'
$ file /usr/local/lib/libodbc.so.1.0.0
/usr/local/lib/libodbc.so.1.0.0: ELF 64-bit LSB shared object,
x86-64, version 1 (SYSV), not stripped
$ more /etc/odbcinst.ini | grep Driver
Driver          = /usr/local/easysoft/oracle/libesoracle.so
Description     = Easysoft ODBC-Oracle Driver
$ file /usr/local/easysoft/oracle/libesoracle.so
/usr/local/easysoft/oracle/libesoracle.so: ELF 64-bit LSB
shared object, x86-64, version 1 (SYSV), not stripped

In the example, the output from the locate command shows that there are two versions of unixODBC on this system. The version in /usr/local/easysoft was included in the ODBC driver distribution. Because the ODBC driver is 64-bit (as proven by running file), the driver manager supplied with it will always be 64-bit also.

Note Not all Unix platforms use ".so" as the shared object file extension. Some versions of HP-UX use ".sl". AIX uses archives (".a") containing shared objects using the ".o" extension.

In this next example, both components of a composite solution (PHP under Apache) are shown to be 64-bit:

$ which httpd
/usr/sbin/httpd
$ file /usr/sbin/httpd
/usr/sbin/httpd: ELF 64-bit LSB shared object, x86-64, 
version 1 (SYSV), for GNU/Linux 2.6.9, stripped
$ locate libphp5.so
/usr/lib64/httpd/modules/libphp5.so

Because the Apache HTTP Server binary is 64-bit, any Dynamic Shared Objects (DSOs) it needs to load must also be 64-bit. Because the DSO module for PHP is located under /usr/lib64, there is no need to use file to verify whether it is 64-bit. Only 64-bit libraries and object files are installed under directories called lib64.

On Windows, run the application and open Task Manager (right-click the taskbar, and then click Task Manager). If the application process has "*32" after its name, it is a 32-bit application. Otherwise, it is a 64-bit application.

Can I use a 32-bit ODBC driver on 64-bit platforms?

Yes. On 64-bit platforms, 32-bit ODBC drivers are available to 32-bit applications, but not to 64-bit applications. What determines your choice of ODBC driver architecture is whether your application is 32-bit or 64-bit not whether your client platform (or database platform or DBMS) is 32-bit or 64-bit.

For example, HSODBC is 32-bit even though it may have been included in a 64-bit Oracle distribution and installed on a 64-bit machine. (HSODBC is an Oracle component which uses ODBC to enable Oracle client applications to transparently access non-Oracle databases.) You therefore must use HSODBC with a 32-bit ODBC driver.

There may be both a 32-bit and a 64-bit ODBC driver available for your platform, but you must use the 32-bit driver if your application is 32-bit.

My database is running on a 64-bit machine. Do I need to use a 64-bit ODBC driver to connect to it?

No. The database platform architecture does not affect whether you need to use a 64-bit or a 32-bit ODBC driver. 64-bit database editions are compatible with 32-bit applications and support client access through a 32-bit ODBC driver without requiring any changes to application code. If your application is 64-bit, you must use a 64-bit ODBC driver regardless of database platform architecture.

Similarly, you can access a 32-bit database edition with either a 64-bit application/ODBC driver or a 32-bit application/ODBC driver.

How do I know whether my ODBC driver for Linux/UNIX platforms is the 64-bit or 32-bit SQLLEN/SQLULEN version?

Easysoft ODBC Drivers

Easysoft ODBC drivers that have been built with 64-bit SQLLEN/SQLULEN types contain "ul64" in their distribution name. For example, "odbc-oracle-3.2.17-linux-x86-64-ul64.tar" is the distribution name for a 64-bit SQLLEN/SQLULEN Oracle ODBC driver.

To find out the name of the distribution your Easysoft ODBC driver was installed from, look at the file /usr/local/easysoft/product_install.info. For example, this .info file for the Oracle ODBC driver shows that the driver was installed from odbc-oracle-3.2.17-linux-x86-64-ul64.tar; the driver is therefore the 64-bit SQLLEN/SQLULEN version.

$ more /usr/local/easysoft/oracle_install.info
product: odbc-oracle
version: /tmp/odbc-oracle-3.2.17-linux-x86-64-ul64
date: Thu Dec 18 10:04:41 GMT 2008

If a 64-bit Easysoft ODBC driver distribution name does not include the "-ul64" suffix, the driver it contains is the 32-bit SQLLEN/SQLULEN version. For example, odbc-sqlserver-1.1.4-linux-x86-64.tar is the distribution name for a 32-bit SQLLEN/SQLULEN SQL Server ODBC driver.

The unixODBC driver manager included in the Easysoft ODBC driver distribution will always have been built with same size SQLLEN/SQLULEN types as the driver it is shipped with.

Non-Easysoft ODBC Drivers

If you can install your ODBC driver under the unixODBC Driver Manager, you can use slencheck, a unixODBC utility which attempts to check whether an ODBC driver was built with 32-bit or 64-bit SQLLEN types.

slencheck is included in unixODBC 2.3.2, which is currently available as a prerelease version. Note that you do not have to replace your existing unixODBC installation with unixODBC 2.3.2 to use slencheck.

These instructions show you how to use slencheck. The instructions assume that you have installed your ODBC driver under a version of unixODBC that came with your driver or OS distribution and that you have configured an ODBC data source for your driver.

  1. Download, build and install unixODBC 2.3.2. For example:
    $ mkdir /home/myuser/unixODBC
    $ cd /tmp
    $ gunzip unixODBC-2.3.2-pre.tar.gz
    $ tar -xvf unixODBC-2.3.2-pre.tar
    $ cd unixODBC-2.3.2-pre
    $ ./configure --prefix=/home/myuser/unixODBC
    $ make
    $ make install

    Replace /home/myuser/unixODBC with the directory where you want to install unixODBC.

  2. Run slencheck against the ODBC data source for your driver.

    The slencheck command line format is:

    slencheck dsn [uid [pwd]]

    where:

    • dsn is your ODBC data source.
    • uid is the user name required to access the target database server, if required and not stored in the data source.
    • password is the password for uid, if required and not stored in the data source.

    For example:

    $ cd /home/myuser/unixODBC/bin
    $ ODBCSYSINI=/etc ./slencheck MYDSN
    slencheck: sizeof(SQLLEN) == 8
    slencheck: driver manager and driver matched

    If slencheck reports the SQLLEN size as 4, the ODBC driver has been built with 32-bit SQLLEN types. If slencheck reports the SQLLEN size as 8, the ODBC driver has been built with 64-bit SQLLEN types.

    Note slencheck probes the unixODBC Driver Manager to determine whether it has been built with the same size SQLLEN types as the ODBC driver. By default, slencheck probes the Driver Manager in the distribution it is included with, not the Driver Manager your ODBC driver is installed under. For example, in the command shown earlier, slencheck probes the Driver Manager in /home/myuser/unixODBC/lib.

How do I obtain a 64-bit or 32-bit SQLLEN/SQLULEN Easysoft ODBC driver for Linux/UNIX platforms?

ProductVersionHow to get
Oracle ODBC Driver64-bit SQLLEN/SQLULENDownload the 64-bit ODBC driver from Easysoft web site.
Oracle ODBC Driver32-bit SQLLEN/SQLULENEmail the Easysoft Support team ().
SQL Server ODBC Driver64-bit SQLLEN/SQLULENDownload the 64-bit ODBC driver from Easysoft web site.
SQL Server ODBC Driver32-bit SQLLEN/SQLULENEmail the Easysoft Support team ().
Salesforce.com ODBC Driver64-bit SQLLEN/SQLULENDownload the 64-bit ODBC driver from Easysoft web site.
Salesforce.com ODBC Driver32-bit SQLLEN/SQLULENEmail the Easysoft Support team ().
DB2 ODBC Driver64-bit SQLLEN/SQLULENDownload the 64-bit ODBC driver from Easysoft web site.
DB2 ODBC Driver32-bit SQLLEN/SQLULENEmail the Easysoft Support team ().
Derby ODBC Driver64-bit SQLLEN/SQLULENDownload the 64-bit ODBC driver from Easysoft web site.
Derby ODBC Driver32-bit SQLLEN/SQLULENEmail the Easysoft Support team ().
Other Easysoft ODBC Driver64-bit SQLLEN/SQLULENEmail the Easysoft Sales team ().
Other Easysoft ODBC Driver32-bit SQLLEN/SQLULENDownload the 64-bit ODBC driver from Easysoft web site.

How do I install both a 32-bit and a 64-bit SQL Server ODBC driver on Linux/UNIX?

  1. Install and license the 32-bit SQL Server ODBC driver.

    For installation instructions, see the ODBC driver documentation. Refer to the documentation to see which environment variables you need to set (LD_LIBRARY_PATH, LIBPATH, LD_RUN_PATH, SHLIB_PATH depending on the platform and linker).

  2. Create an ODBC data source in /etc/odbc.ini that connects to the target database.
  3. To verify the 32-bit ODBC driver installation, use isql to connect to the new data source. For example:
    $ cd /usr/local/easysoft/unixODBC/bin
    $ ./isql.sh -v MSSQL-DSN

    At the prompt, type "help" to display a list of tables. To exit, press return in an empty prompt line.

  4. Install the 64-bit SQL Server ODBC driver:
    1. When the installer asks you to "Enter a base install directory", type:
      /usr/local/easysoft64
    2. Make sure that you do not use the unixODBC Driver Manager the installer finds in /usr/local/easysoft/unixODBC.
    3. Do not replace the sample data source.
    4. Do not request a new license unless you are installing a Linux x86_64 ODBC driver distribution.
  5. Create the following links between the 32-bit and 64-bit installations:
    # cd /usr/local/easysoft
    # ln -s /usr/local/easysoft64/easysoft/lib lib64
    # ln -s /usr/local/easysoft64/easysoft/etc etc64
    # ln -s /usr/local/easysoft64/easysoft/sqlserver sqlserver64
    # cd unixODBC
    # ln -s /usr/local/easysoft64/easysoft/unixODBC/bin bin64
    # ln -s /usr/local/easysoft64/easysoft/unixODBC/lib lib64
  6. Add entries for both the 32-bit and 64-bit ODBC driver to /etc/odbcinst.ini.

    In the /etc/odbcinst.ini section for the ODBC driver, specify the 32-bit ODBC driver shared object with the Driver attribute; add a Driver64 attribute that specifies the 64-bit ODBC driver shared object.

    For example, this /etc/odbcinst.ini section specifies just the shared object for the 64-bit SQL Server ODBC driver:

    [Easysoft ODBC-SQL Server]
    Driver=/usr/local/easysoft64/easysoft/sqlserver/lib/libessqlsrv.so
    Setup=/usr/local/easysoft64/easysoft/sqlserver/lib/libessqlsrvS.so
    Threading=0
    FileUsage=1
    DontDLClose=1
    UsageCount=2

    The section has now been changed to specify both the 32-bit and 64-bit ODBC driver shared objects:

    [Easysoft ODBC-SQL Server]
    Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv.so
    Driver64=/usr/local/easysoft/sqlserver64/lib/libessqlsrv.so
    Setup=/usr/local/easysoft64/easysoft/sqlserver/lib/libessqlsrvS.so
    Threading=0
    FileUsage=1
    DontDLClose=1
    UsageCount=2
  7. Edit the startup file for isql to specify the correct library paths. (Note You will need to make the same changes to the library search path for your application.)
    1. Open /usr/local/easysoft/unixODBC/bin64/isql.sh in a text editor.
    2. Change these lines:
      if [ -r /usr/local/easysoft/etc/es.ld.so.conf ];then
      ldpaths=`cat  /usr/local/easysoft/etc/es.ld.so.conf `

      To:

      if [ -r /usr/local/easysoft/etc64/es.ld.so.conf ];then
      ldpaths=`cat  /usr/local/easysoft/etc64/es.ld.so.conf `
    3. Change this line:
      /usr/local/easysoft/unixODBC/bin/isql $*

      To:

      /usr/local/easysoft/unixODBC/bin64/isql $*
  8. If you are using Linux x86/x86_64 ODBC driver distributions, you need a license for both the 32-bit and 64-bit ODBC drivers. The two licences can be obtained during the installation and the license entry from the two license files can be combined into the one file:
    # cat /usr/local/easysoft64/easysoft/license/licenses >> /usr/local/easysoft/license/licenses
  9. Test the 64-bit SQL Server ODBC driver installation:
    $ /usr/local/easysoft/unixODBC/bin64/isql.sh -v MSSQL-DSN
  10. Test the existing 32-bit SQL Server ODBC driver installation:
    $ /usr/local/easysoft/unixODBC/bin/isql.sh -v MSSQL-DSN

How do I install both a 32-bit and a 64-bit Easysoft ODBC driver on Windows?

On 64-bit Windows platforms, the Easysoft ODBC driver installation program installs both a 32-bit and a 64-bit version of the ODBC driver. On 64-bit Windows platforms therefore, Easysoft ODBC drivers are automatically available to both 32-bit and 64-bit applications.

Why do I get error "testlib: not found" not found when installing a 32-bit Easysoft ODBC driver on my 64-bit Linux machine?

Easysoft ODBC driver distributions contain a small C program named testlib, which is run during installation to make sure that the prerequisite C runtime libraries are present. If the 32-bit C runtime libraries are not installed on your 64-bit machine, which is the case in some of the more recent 64-bit Linux distributions, testlib will not be visible to your (64-bit) C runtime and the Easysoft installation will abort with an error similar to:

Testing this machine for libc5/glibc compatability.
./install_check_linux: 121: ./testlib: not found

The solution is to install the 32-bit C runtime libraries, which in some Linux distributions are contained in the libc6-i386 package.

testlib is described in more detail in this Easysoft Knowledge Base article.

Can I use a 64-bit Easysoft ODBC-ODBC Bridge Client with a 32-bit Easysoft ODBC-ODBC Bridge Server?

Yes. You can use a 64-bit ODBC-ODBC Bridge Client with a 32-bit ODBC-ODBC Bridge Server and a 32-bit ODBC-ODBC Bridge Client with a 64-bit ODBC-ODBC Bridge Server.

The application and the ODBC driver you need the ODBC-ODBC Bridge to provide the connectivity between dictate whether you need to use a 32-bit or 64-bit ODBC-ODBC Bridge component.

If the application that you want to use the ODBC-ODBC Bridge Client with is 32-bit, you must use a 32-bit ODBC-ODBC Bridge Client. If the application that you want to use the ODBC-ODBC Bridge Client with is 64-bit, you must use a 64-bit ODBC-ODBC Bridge Client.

If the ODBC driver that you want to use the ODBC-ODBC Bridge Server with is 32-bit, you must use a 32-bit ODBC-ODBC Bridge Server. If the ODBC driver that you want to use the ODBC-ODBC Bridge Server with is 64-bit, you must use a 64-bit ODBC-ODBC Bridge Server.

A 32-bit ODBC-ODBC Bridge Client can connect to a 64-bit ODBC-ODBC Bridge Server and vice versa. For example, using a 64-bit ODBC-ODBC Bridge Client with a 32-bit ODBC-ODBC Bridge Server enables a 64-bit application to connect to a data source for a 32-bit ODBC driver.

To illustrate this, we used the ODBC-ODBC Bridge for Windows to connect a 64-bit Strawberry Perl distribution to a data source for the 32-bit Microsoft Access ODBC driver:

  1. On our 64-bit Windows machine, we ran the following command to verify that we were using a 64-bit Strawberry Perl distribution:
    perl -V

    In the command output archname=MSWin32-x64-multi-thread, confirms that the Perl distribution is 64-bit.

  2. We configured and tested a Microsoft Access ODBC driver data source and attempted to connect to the data source with the following Perl script:
    #!/usr/bin/perl -w
    use strict;
    use DBI;
    my $dbh = DBI-> connect('dbi:ODBC:Northwind');
    $dbh->disconnect if ($dbh);
    
  3. As expected, attempting to use a 64-bit application with a 32-bit ODBC driver failed, and we got the following error when running the script:
    [Microsoft][ODBC Driver Manager]
    The specified DSN contains an architecture mismatch between the Driver and Application
  4. We then installed the 64-bit Windows ODBC-ODBC Bridge distribution.

    We accepted the Default option during Setup, which installed both the ODBC-ODBC Bridge Client and Server components.

  5. Using the 64-bit ODBC Administrator (accessible from Administrative tools in Control Panel), we configured an ODBC-ODBC Bridge Client data source that pointed to our Access ODBC driver data source.
  6. We changed the Perl script to specify the ODBC-ODBC Bridge Client data source.
    my $dbh = DBI-> connect('dbi:ODBC:ODBC-ODBC Bridge_Northwind');
    

    The script then ran successfully.

Can I connect a 64-bit application to a 32-bit ODBC driver and vice versa?

Yes, you can use the ODBC-ODBC Bridge to connect a 64-bit application to a 32-bit ODBC driver and a 32-bit application to a 64-bit ODBC driver. For more information, see:

Appendix A: Resources

Article Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)