Next: 2.4 Using MIDAS with Up: 2 Getting started Previous: 2.2 Compiling with MIDAS

# 2.3 Linking with MIDAS

If your program uses MIDAS Sound System, you naturally need to link with the MIDAS libraries as well. This section describes how to do that on each platform supported.

All MIDAS libraries are stored under the `lib/` subdirectory in the distribution. `lib/` contains a subdirectory for each supported platform, and those in turn contain directories for each supported compiler. The format of the compiler directory names is ``<compiler><build>'', where <compiler> is a two-letter abbreviation for the compiler name, and <build> the library build type -- retail or debug. Under most circumstances, you should use the retail versions of the libraries, as they contain better optimized code. Also, the debug libraries are not included in all releases.

For example, `lib/win32/vcretail/midas.lib` is the retail build of the Win32 Visual C/C++ static library.

## 2.3.1 Windows NT/95

Under the Win32 platform, applications can link with MIDAS either statically or dynamically. Unless there is a specific need to link with MIDAS statically, dynamic linking is recommended. Delphi users need to use dynamic linking always.

When linking with MIDAS statically, simply link with the library file corresponding to your development platform. For Watcom C/C++, the library is `lib/win32/wcretail/midas.lib`, and for Visual C/C++ `lib/win32/vcretail/midas.lib`. Depending on your configuration, you may need to add the library directory to your ``library paths'' list. When MIDAS is linked into the application statically, the .exe is self-contained and no MIDAS `.dll` files are needed.

Dynamic linking is done by linking with the appropriate MIDAS import library instead of the static linking library. In addition, the MIDAS Dynamic Link Library (`midasXX.dll`) needs to be placed in a suitable directory -- either to the same directory with the program executable, or in some directory in the user's PATH. The import libraries are stored in the same directory with the static libraries, but the file name is `midasdll.lib`. For example, Visual C users should link with `lib/win32/vcretail/midasdll.lib`. The MIDAS Dynamic Link Libraries are stored in `lib/win32/retail` and `lib/win32/debug`.

Delphi users do not need a separate import library -- using the interface unit `midasdll.pas` adds the necessary references to the `.dll` automatically. Note that running the program under the Delphi IDE without the `.dll` available can cause strange error messages.

## MS-DOS

As MS-DOS doesn't support dynamic linking, only a static link library is provided for MS-DOS. You'll simply need to link file `midas.lib` from the appropriate subdirectory -- usually `lib/dos/gcretail` for GCC (DJGPP) and `lib/dos/wcretail` for Watcom C. The executable is fully self-contained, and no additional files are needed.

Note that some versions of the Watcom Linker are not case-sensitive by default, and you'll need to use case-sensitive linking with MIDAS. To do that, simply add `option caseexact` to your linker directives.

## 2.3.3 Linux

For Linux, both dynamic and static libraries are provided. To link your program with MIDAS, add the proper MIDAS library directory (usually `lib/linux/gcretail`) to your library directory list (gcc option `-L`), and link the library in using the GCC option `-lmidas`. Depending on whether you are building a statically or dynamically linked program, GCC will automatically select the correct library.

Next: 2.4 Using MIDAS with Up: 2 Getting started Previous: 2.2 Compiling with MIDAS