#
Building libsndfile on Win32

There are currently two ways of building libsndfile under Win32:

- Using the free MinGW tools.
- Using Microsoft's Visual C++ tools.

The free MinGW tools are the preferred option because they are a free (as in beer and speech), easily obtainable and much closer to the Linux/GCC environment on which libsndfile is developed. At some time in the near future I intend to drop support for Microsoft's tools. Yes, I know there is now a free (as in beer, but not as in speech) version of Microsoft's tools, but I believe that the only reason Microsoft released these free tools was because of the growing popularity of the MinGW tools.

##
Building libsndfile using MinGW.

The MinGW tools are available from http://www.mingw.org/. The files you will need will be named something like:

- msysDTK-1.0.1.exe
- MSYS-1.0.10.exe
- gcc-core-3.3.1-20030804-1.tar.gz
- gcc-g++-3.3.1-20030804-1.tar.gz
- binutils-2.13.90-20030111-1.tar.gz
- mingw-runtime-3.2.tar.gz
- w32api-2.5.tar.gz
- mingw-utils-0.3.tar.gz

They should be installed using the directions on the MinGW site. I know the instructions aren't great, but I don't have the time or expertise to write better ones.

Once you have the tools installed you will get an icon named MSYS on your desktop. Clicking on that icon will bring up something that looks a little like an xterm.

Assuming that you have downloaded the .tar.gz file into the C:\temp\ directory you should now be able to execute the following commands:

    		tar zxf /c/temp/libsndfile.X.Y.Z.tar.gz
    		cd libsndfile-X.Y.Z
    		./configure
    		make
    		make check

If there is a failure during compiling or the "make check" stage, you should check that you are using the current stable version of the MinGW tools, and the latest version of libsndfile before sending the author a bug report.

Once this is done, anyone interested in using libsndfile in other projects will be interested in the following files:

- libsndfile.dll
- libsndfile.lib
- libsndfile.def
- src/sndfile.h
- doc/*.html

##
Building libsndfile using MSVC++ 6.

For Win32 there is a Microsoft Visual C++ compatible makefile in the Win32\ directory of the distribution. Building the libsndfile DLL on Win32 involves the following:

1. Using WinZip in the GUI, open the libsndfile-1.X.Y.tar.gz file and extract the files into a directory. The following example assumes C:\.
2. In the directory containing the extracted files, find the file Win32\Makefile.msvc and open it in a text editor (ie Notepad or similar).
3. Find the line which starts with MSVCDir and modify the directory path to point to the location of MSVC++ on your machine. This allows the makefile to inform the compiler of the location of the standard header files. Note that none of the directory names are allowed to have spaces in them.
4. Copy the file named sndfile.h from the Win32\ directory to the src\ directory replacing the one that was originally there.
5. Copy the file named config.h from the Win32\ directory to the src\ directory replacing the one that was originally there.
6. Open a DOS window and cd into the libsndfile-1.X.Y directory.
7. Make sure that the program nmake (which is part of the MSCV++ package) is in a directory which is part of your PATH variable.
8. Type in the command

       C:\libsndfile-1.X.Y> nmake -f Win32\Makefile.msvc

   and press <return>. You should now see a a large number of compile commands as libsndfile.dll is built. If this command fails, that may mean that nmake is not in a directory specified by your PATH environment variable.
9. To check that the built DLL has been compiled correctly type in and run the command

       C:\libsndfile-1.X.Y> nmake -f Win32\Makefile.msvc check

   which will compile a set of test programs and run them. If any of the programs fail the error message will be helpful in debugging the problem.

At the end of the above procedure, you will find the DLL, libsndfile.dll and a LIB file libsndfile.lib in the current directory. These two files, along with the header file sndfile.h (in the Win32\ directory) are all that you need to copy to your project in order to use libsndfile.

##
Compile Problems

Compile problems using the above method of building the libsndfile DLL on Win32 should be emailed to Erik de Castro Lopo. This includes error messages generated during step 7 above.

If you are using some other method to compile the libsndfile DLL you are on your own.