Difference between revisions of "OpenDBX/Setup/Windows/Building with MinGW"

From Linuxnetworks
Jump to: navigation, search
(MySQL backend instructions for Win32)
(reordered backends)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries, augmenting the GNU Compiler Collection, (GCC), and its associated tools, (GNU binutils). MinGW provides a complete Open Source programming tool set which is suitable for the development of native Windows programs that do not depend on any 3rd-party C runtime DLL.
 
MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries, augmenting the GNU Compiler Collection, (GCC), and its associated tools, (GNU binutils). MinGW provides a complete Open Source programming tool set which is suitable for the development of native Windows programs that do not depend on any 3rd-party C runtime DLL.
 +
 +
__TOC__
 +
 +
== Requirements ==
  
 
Download the following packages from the [http://sourceforge.net/project/showfiles.php?group_id=2435 MinGW Sourceforge] page:
 
Download the following packages from the [http://sourceforge.net/project/showfiles.php?group_id=2435 MinGW Sourceforge] page:
Line 30: Line 34:
  
 
All backends could be build invoking ./configure like shown below. Please keep in mind that the paths may differ depending on the location of the installed packages:
 
All backends could be build invoking ./configure like shown below. Please keep in mind that the paths may differ depending on the location of the installed packages:
 +
 +
=== Firebird ===
 +
 +
After installing the Firebird package from the [http://firebirdsql.org/index.php?op=files&id=engine website], you have to rename the file
 +
 +
fbclient_ms.lib to libfbclient_ms.dll
 +
 +
in the firebird "lib/" directory which is usually in "C:\Progra~1\Firebird\Firebird_2_1\lib". Otherwise, autoconf and libtool won't find the file and no DLL is generated. Building the firebird backend is possible using this command:
 +
 +
CPPFLAGS="-I/c/Progra~1/Firebird/Firebird_2_1/include" \
 +
LDFLAGS="-L/c/Progra~1/Firebird/Firebird_2_1/lib" \
 +
./configure --with-backends="firebird"
 +
 +
=== MS SQL Server ===
 +
 +
The mssql backend is primarily intended for Unix environments where a native client library is not available for the MS SQL Server and FreeTDS library provides the only alternative. On Windows platforms, the native client is an ODBC driver so it's better to use the [[OpenDBX/Setup/Windows/Building_with_MinGW#ODBC|odbc backend]].
  
 
=== MySQL ===
 
=== MySQL ===
Line 40: Line 60:
 
Otherwise, the libmysql.dll file isn't installed in the "bin\" directory and the files in the "include\" and "lib\opt\" directory are not available.
 
Otherwise, the libmysql.dll file isn't installed in the "bin\" directory and the files in the "include\" and "lib\opt\" directory are not available.
  
The OpenDBX MySQL backend doesn't build out of the box as the mysql.h file is not prepared to be used with MinGW. Fortunately, applying a simple hack to the mysql.h file does fix the problem: Change the line
+
Autoconf and Libtool seem to have problems finding the "mysql.lib" file in the "lib\opt\" directory. As a workaround, you have to rename the file
  
  #ifdef __CYGWIN__
+
  mysql.lib to libmysql.dll
  
to
+
The call to the ./configure script depends on the location of the files. The paths below are for MySQL 5.1 and if you've installed a different version or installed it to a different path, please adapt the paths as necessary. Especially the "MySQLS~1.1" part has to be changed for different versions of the MySQL package.
  
  #ifndef __CYGWIN__
+
  CPPFLAGS="-I/c/Progra~1/MySQL/MySQLS~1.1/include/" \
 +
LDFLAGS="-L/c/Progra~1/MySQL/MySQLS~1.1/lib/opt" \
 +
./configure --with-backends="mysql"
  
and you are able to use the mysql.h file for compilation. Otherwise, you will get a lot of error messages.
+
=== ODBC ===
  
The call to the ./configure script depends on the location of the files. The paths below are for MySQL 5.1 and if you've installed a different version or installed it to a different path, please adapt the paths as necessary. Especially the "MySQLS~1.1" part has to be changed for different versions of the MySQL package.
+
The odbc backend can be compiled out of the box in the MinGW environment:
  
  CPPFLAGS=" \
+
  ./configure --with-backends="odbc"
  -I/c/Progra~1/MySQL/MySQLS~1.1/include/ \
+
 
  " \
+
=== Oracle ===
  LDFLAGS=" \
+
 
  -L/c/Progra~1/MySQL/MySQLS~1.1/bin \
+
Building the oracle backend requires one of the product editions available from the [http://www.oracle.com/database/index.html Oracle website] which contains the include and DLL files. After installing the package on your machine you have to rename the file
  -L/c/Progra~1/MySQL/MySQLS~1.1/lib/opt \
+
 
  " \
+
oci.lib to liboci.dll
  ./configure --with-backends="mysql"
+
 
 +
in the "lib" directory to enable autoconf and libtool to find the library. You may find the "lib" directory somewhere below the directory where you've installed the Oracle files. Depending on that, you have to adapt the paths in the command for building the backend:
 +
 
 +
CPPFLAGS="-I/c/Progra~1/Oracle/product/11.1.0/instantclient_11_1/sdk/include" \
 +
  LDFLAGS="-L/c/Progra~1/Oracle/product/11.1.0/instantclient_11_1" \
 +
  ./configure --with-backends="oracle"
 +
 
 +
=== PostgreSQL ===
 +
 
 +
The pgsql backend builds out of the box using the command below but you eventually have to adapt the path to the PostgreSQL directory:
 +
 
 +
CPPFLAGS="-I/c/Progra~1/Postgr~1/8.4/include"
 +
LDFLAGS="-L/c/Progra~1/Postgr~1/8.4/bin" \
 +
./configure --with-backends="pgsql"
 +
 
 +
=== SQLite ===
 +
 
 +
On Windows platforms only the sqlite3 backend is available as the required source or DLL for building the sqlite backend is not available any more from sqlite.org.
 +
 
 +
You need the sqlite3.dll and the sqlite3.h file from [http://sqlite.org/download.html sqlite.org] in order to compile the sqlite3 backend. Save them to
 +
 
 +
C:\Progra~1\msys\local\lib\libsqlit3.dll
 +
C:\Progra~1\msys\local\include\sqlite3.h
 +
 
 +
Now you can build the sqlite3 backend using
 +
 
 +
CPPFLAGS="-I/c/local/include/" \
 +
  LDFLAGS="-L/c/local/lib"
 +
  ./configure --with-backends="sqlite3"
 +
 
 +
=== Sybase ===
 +
 
 +
After installing the Sybase Adaptive Server Enterprise (Sybase ASE 15) package, you can build the sybase backend using
  
=== Other ===
+
CPPFLAGS="-I/c/Progra~1/sybase/OCS-15_0/include/" \
 +
LDFLAGS="-L/c/Progra~1/sybase/OCS-15_0/dll" \
 +
./configure --with-backends="sybase"
  
CPPFLAGS=" \
+
The path to the directory where the Sybase files are installed depends on your choice during the installation process. Please adapt it to your needs.
  -I/c/Progra~1/PostgreSQL/8.3/include/ \
+
  -I/c/Progra~1/Firebird/Firebird_2_1/include/ \
+
  -I/c/Progra~1/sybase/OCS-15_0/include/ \
+
  -I/c/Progra~1/Oracle/product/11.1.0/instantclient_11_1/sdk/include \
+
  -I/c/Progra~1/GnuWin32/include \
+
" \
+
LDFLAGS=" \
+
  -L/c/Progra~1/PostgreSQL/8.3/bin \
+
  -L/c/Progra~1/Firebird/Firebird_2_1/lib \
+
  -L/c/Progra~1/Firebird/Firebird_2_1/bin \
+
  -L/c/Progra~1/sybase/OCS-15_0/dll \
+
  -L/c/Progra~1/Oracle/product/11.1.0/instantclient_11_1 \
+
  -L/c/Progra~1/GnuWin32/lib \
+
" \
+
./configure --with-backends="mssql odbc oracle pgsql sqlite3 sybase"
+

Latest revision as of 17:20, 30 August 2009

MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries, augmenting the GNU Compiler Collection, (GCC), and its associated tools, (GNU binutils). MinGW provides a complete Open Source programming tool set which is suitable for the development of native Windows programs that do not depend on any 3rd-party C runtime DLL.

Requirements

Download the following packages from the MinGW Sourceforge page:

  • Automated MinGW installer
  • MSYS base system (executable of current release)

There are some tutorials available, how to install MinGW:

The steps to build the OpenDBX library are the same as in the Unix environment.

It's hard to build the applications in the "utils/" directory because of the dependencies. The easiest way is to disable building the utilities. Alternatively, you can try installing the required header and library files (complete sources) for Windows:

By default, the packages are installed in "C:\Program Files\GnuWin32", so you have to add the "include/" and "lib/" directory to ./configure:

CPPFLAGS="-I/c/Progra~1/GnuWin32/include" \
LDFLAGS="-L/c/Progra~1/GnuWin32/lib" \
./configure --with-backends="sqlite3"

Please note that it seems not be possible to use "Program Files" instead of "Progra~1" as this leads to a weird error message that the C compiler cannot create executables.

Backends

All backends could be build invoking ./configure like shown below. Please keep in mind that the paths may differ depending on the location of the installed packages:

Firebird

After installing the Firebird package from the website, you have to rename the file

fbclient_ms.lib to libfbclient_ms.dll

in the firebird "lib/" directory which is usually in "C:\Progra~1\Firebird\Firebird_2_1\lib". Otherwise, autoconf and libtool won't find the file and no DLL is generated. Building the firebird backend is possible using this command:

CPPFLAGS="-I/c/Progra~1/Firebird/Firebird_2_1/include" \
LDFLAGS="-L/c/Progra~1/Firebird/Firebird_2_1/lib" \
./configure --with-backends="firebird"

MS SQL Server

The mssql backend is primarily intended for Unix environments where a native client library is not available for the MS SQL Server and FreeTDS library provides the only alternative. On Windows platforms, the native client is an ODBC driver so it's better to use the odbc backend.

MySQL

For building the OpenDBX MySQL backend, you need to install the "Windows Essentials" available in the download section of the MySQL website. A minimal install must consist of

Client Programs -> MySQL Command Line Utilities
C Include Files / Lib Files

Otherwise, the libmysql.dll file isn't installed in the "bin\" directory and the files in the "include\" and "lib\opt\" directory are not available.

Autoconf and Libtool seem to have problems finding the "mysql.lib" file in the "lib\opt\" directory. As a workaround, you have to rename the file

mysql.lib to libmysql.dll

The call to the ./configure script depends on the location of the files. The paths below are for MySQL 5.1 and if you've installed a different version or installed it to a different path, please adapt the paths as necessary. Especially the "MySQLS~1.1" part has to be changed for different versions of the MySQL package.

CPPFLAGS="-I/c/Progra~1/MySQL/MySQLS~1.1/include/" \
LDFLAGS="-L/c/Progra~1/MySQL/MySQLS~1.1/lib/opt" \
./configure --with-backends="mysql"

ODBC

The odbc backend can be compiled out of the box in the MinGW environment:

./configure --with-backends="odbc"

Oracle

Building the oracle backend requires one of the product editions available from the Oracle website which contains the include and DLL files. After installing the package on your machine you have to rename the file

oci.lib to liboci.dll

in the "lib" directory to enable autoconf and libtool to find the library. You may find the "lib" directory somewhere below the directory where you've installed the Oracle files. Depending on that, you have to adapt the paths in the command for building the backend:

CPPFLAGS="-I/c/Progra~1/Oracle/product/11.1.0/instantclient_11_1/sdk/include" \
LDFLAGS="-L/c/Progra~1/Oracle/product/11.1.0/instantclient_11_1" \
./configure --with-backends="oracle"

PostgreSQL

The pgsql backend builds out of the box using the command below but you eventually have to adapt the path to the PostgreSQL directory:

CPPFLAGS="-I/c/Progra~1/Postgr~1/8.4/include"
LDFLAGS="-L/c/Progra~1/Postgr~1/8.4/bin" \
./configure --with-backends="pgsql"

SQLite

On Windows platforms only the sqlite3 backend is available as the required source or DLL for building the sqlite backend is not available any more from sqlite.org.

You need the sqlite3.dll and the sqlite3.h file from sqlite.org in order to compile the sqlite3 backend. Save them to

C:\Progra~1\msys\local\lib\libsqlit3.dll
C:\Progra~1\msys\local\include\sqlite3.h

Now you can build the sqlite3 backend using

CPPFLAGS="-I/c/local/include/" \
LDFLAGS="-L/c/local/lib"
./configure --with-backends="sqlite3"

Sybase

After installing the Sybase Adaptive Server Enterprise (Sybase ASE 15) package, you can build the sybase backend using

CPPFLAGS="-I/c/Progra~1/sybase/OCS-15_0/include/" \
LDFLAGS="-L/c/Progra~1/sybase/OCS-15_0/dll" \
./configure --with-backends="sybase"

The path to the directory where the Sybase files are installed depends on your choice during the installation process. Please adapt it to your needs.