How to build UNIX libraries with MSVC 7

2004/08/03 by Steve Lhomme

Introduction

My goal is to build GStreamer under Windows using the standard compiler from Microsoft (found in Visual Studio). That should make debugging these libraries much easier than using libraries compiled with MinGW32. That may also make these libraries run faster and take less space (in Release mode). In other words, that's a good environment to work with, and with which many (more) developers are used to under Windows.

Most of the libraries I found existed in one form or another as DLLs built either with MinGW32 or with MSVC. But they used different name for the built packages, making it hard to use with one another and somehow unreliable. So I decided to make my own clean environment. So that I could fix potential bugs where found (don't expect UNIX devs to really care about the Windows world).

Packages

The packages I needed to have are the following:

Getting started

First of all, you need some of these packages already compiled to be able to compile them... For example gettext needs the .h and .lib of iconv, and iconv needs the .h and .lib of gettext.

So you first need to get either the corresponding packages. There is either a Release version and a Debug version of the package. It's called gstreamer-win32-deps-XXX.rar and gstreamer-win32-dev-deps-XXX.rar respectively. XXX being the version number of the package (currently 2). Then you have to decompress the package to c:\ by default. You will end up with a directory hierarchy like this:

Getting the sources

Now if you want to debug these packages, you probably want to compile them yourself. You need to get the sources for that. Right now the only solution is to get the large package of source I have because my changes are not in the official sources yet. I will send patches to each project hoping my changes will become official. The patches are available below. This package include the following:

Compiling the sources

All you need is to have MSVC installed (tested with Microsoft Visual Studio .Net 2003 == MSVC7.1) on your computer. You also need nmake.exe, cl.exe and lib.exe in your PATH.

Then go in the same directory as there is README.html and execute the following command:

nmake -f makefile.msvc DEBUG=1

This command will build all the libraries in Debug mode. You can also use DEBUG=0 for a Release build.

After this, you should install the libraries and headers in the correct system locations (as found in gettext and libiconv):

nmake -f makefile.msvc DEBUG=1 install

If you want to install the Release build now, you should clean the Debug build first, compile again and then install:

nmake -f makefile.msvc DEBUG=1 clean
nmake -f makefile.msvc DEBUG=0
nmake -f makefile.msvc DEBUG=0 install

Finally you may also decide to remove what you just installed:

nmake -f makefile.msvc DEBUG=1 uninstall

Epilogue

Now you can safely compile GStreamer and GST-plugins with this environment in place. You can also debug directly from MSVC as the .PDB files are included for the Debug build.