Compiling on Cygwin
|Compiling under Cygwin is not maintained and not recommended. If you do do this and succeed please let us know and help us update these instructions. These are very old instructions!|
These instructions will attempt to help you to compile using the experimental additions that appeared sometime around the 1.2 release. They will also attempt to help you to compile Audacity yourself without the aforementioned support. Make sure to read the instructions in their entirety before beginning, because no matter which source tree you wind up using, all of these instructions are likely to assist you.
If you have problems building, make sure you've read all of these instructions. At the bottom there is a list of known bugs. If the problem you encounter is on this list, then there is also a workaround. Just remember to be patient, and that I (Dave Fancella) have successfully built Audacity on 3 different Windows installations with 2 different versions of Windows (XP and 2000 Pro). Knowing that it can be done is most of the battle.
1. Install Cygwin (from "http://www.cygwin.com"). If you have
plenty of bandwidth available, you should use the net installer. Otherwise, you might be better off ordering a CD.
2. If you already have Cygwin installed, you should fire up
the installer again and compare your installed packages to the list of packages needed.
3. Install the following packages:
(This is probably not a complete list. If you find that you have to install more than this, make sure to let us know which ones, so they can be added to this list) Autoconf Autoconf-devel (Autoconf 2.53 is required if you need to rebuild 'configure') gettext-devel (for building the translation files. If you don't want to build these, you don't need this package) Automake Automake-devel binutils gcc (only tested version is 3.3.1) gcc-mingw make mingw-runtime zip (required by configure, although gzip is actually used) w32api
Download and install wxWidgets
1. Go to http://www.wxwidgets.org/ and download wxWidgets v3.0.2 or greater. Make sure you download the "wxAll" package that contains source code for all ports. The Win32 port will not work for compiling Audacity, since it was compiled and installed to work with MS Visual C++.
2. Untar the archive from the Cygwin command line, using a command like: tar -xzvf (wxwindows).
3. From the top-level of the wxWidgets source tree, type './configure'.
- For some reason, I haven't been able to get Audacity to link to wxWidgets statically
under Cygwin. Since there are bigger fish to fry right now, I haven't dealt with it. I would appreciate if someone gets it to work if you let me know what you did. To try this, use './configure --disable-shared' for wxWidgets configuration.
When complete, type "make". When that's complete, "make install". If all goes well, you will have wxWidgets installed in your Cygwin installation!
Either use Git, with a command like
git clone https://github.com/audacity/audacity
to get a local copy of our repository. OR fetch the tarball (link is at http://audacityteam.org/download/source) and then from a cygwin prompt, use a command like
'tar -xzvf (audacity tarball)'
to open it.
Enable Ogg Vorbis Support
Under Cygwin, Audacity does not compile out-of-the-box with Ogg Vorbis support. You have a couple of hoops to jump through if you want this. Note, if you don't do this, you will not have any audio codec available to Audacity! Lame is untested at this time and is assumed not to work. If you try it with Lame, tell us!
By default, libogg and libvorbis configure with /usr/local as the prefix. For some weird and inexplicable reason (i.e. I haven't figured it out yet) this doesn't work! GCC will not find the libogg headers when you go to compile libvorbis if you install it in the default location. On that token, GCC will not find libvorbis headers either, so make sure you follow these instructions explicitly.
1. First you have to compile libogg. From the audacity source tree root, type 'cd lib-src/libogg'.
2. ./configure --prefix=/usr
4. make install
5. cd ../libvorbis # yep, now we have to compile vorbis
6. ./configure --prefix=/usr
8. make install
If all goes well, you will have Ogg Vorbis support in your Audacity executable.
This is the tricky part. :)
Audacity comes bundled with a number of libraries that it depends on. Usually you will compile with those rather than any system installed libraries. If you would prefer to use a system installed library, you'll have to pass --with-library=/path/to/library to configure. There are two libraries that currently do not compile in cygwin. Those are Nyquist and libid3tag. If you manage to build them, please send a patch (or instructions on how you did it)!
If you didn't enable Ogg Vorbis support as described in the previous step, you will have to pass --without-vorbis to configure, as shown.
1. ./configure --without-nyquist --without-id3tag [--without-vorbis] 2. make 3. ./audacity 4. If you have any problems or errors, read the next section.
Notes on building Audacity with Cygwin
These notes are provided because Cygwin support is experimental, and if you run into problems, it might help to know what was needed to make it work on my computer.
The problems that appear when compiling Audacity under Cygwin are pretty consistent in how they appear. The win32 port is written under the assumption that MSVC++ will be the compiler used, and is the current standard and supported method of building Audacity. Therefore, the problems that appear are mostly related to various symbols defined to make Audacity compile out of the box on MSVC++. Other problems that surface will likely be based on the fact that Cygwin passes itself to configure as a UNIX variant, and there are various other symbols defined for UNIX variants. GNU/Linux is the standard UNIX variant supported by Audacity, so you will have problems similar to what someone using OpenBSD might encounter. The exception is Mac OS X, which is well-supported already.
Audacity uses a series of libraries that are either required or optional, and can be set at compile time. The ones that are optional have --without switches for configure, the others do not. So if a bundled library doesn't compile, your best bet is to try disabling the library in your configure command line. If that doesn't work, you'll have to investigate the library to see why it's not compiling.
PortAudio is required, and a Makefile is provided with Audacity to build it. PortMixer is not required, but is recommended. This Makefile is also provided with Audacity. Note: to my knowledge, the Makefile for PortAudio provided with Audacity is not present in the PortAudio distribution. The one used with Audacity compiles PortAudio as a static library, and the current Cygwin Makefile in the PortAudio distribution compiles as a dynamic library. Audacity will compile with either one, but if you use the one provided with PortAudio you will have to make sure the PortAudio dll is in Audacity's path. Of course, you shouldn't have any problems, so this is probably more information than you need. :)
Expat should compile out of the box. If not, you might be better off trying to install the version of expat that ships with Cygwin. If configure fails to detect a system installed expat, this is probably a bug and should be submitted to the Audacity developers. You can use the system-installed expat by passing --with-expat=system to ./configure.
Any other libraries are probably not required, and if they fail to compile you should be able to --disable them with configure.
Configwin.h is a file that exists in the win directory from the root of Audacity's source tree. You have three options for getting gcc to find this file. You can modify Audacity's Makefile to include -I../win (or whatever a good path is that will point at the directory). You can copy or move the configwin.h file to Audacity's source directory. Preferably, you will modify configure.ac to generate configwin.h in exactly the same fashion and location that it already generates configunix.h.
A fourth option is to not use Configwin.h at all, but to modify the appropriate header files to use configunix.h. Since this might be similar to opening a can of worms, I don't recommend this approach.
Dealing with #defines
While working with this build system, there were a few files that failed to compile. Whenever make bombs on a file, you need to carefully note the line it made the error on and open the source file in a good syntax highlighting editor, or you can use Wordpad, which is neither good nor syntax highlighting. Find the appropriate line on which the error occurred. Then scroll up. Chances are very good that the line that triggered the error is wrapped in a #ifndef,
- if defined, or #ifdef block. The #define symbol is usually __WIN32__. You will be able to
get it to compile by making the line read something like this:
- if defined(__WIN32__) && !defined(__CYGWIN__)
In order for that to work, you will need to make sure that configure sets the __CYGWIN__ symbol to be defined. You may be able to just add it to Audacity's Makefile, however. If you chose to use the existing Configwin.h file and not have it generated by configure, then you should be able to add a #define in it that defines __CYGWIN__.
Ultimately, if you find any of these options too difficult or time-consuming, you might consider just deleting the entire block of code that is afflicted. Since that route will likely wind up making the job hundreds of times more difficult than it actually is, it is not recommended.
The normal Unix flags for linking will not work with Audacity. Well, they will but they won't include everything that needs to be linked. Before discussing what actually needs to be linked, it would be beneficial to discuss the win32api and Cygwin.
Cygwin is capable of compiling Windows programs that do not depend on the Cygwin runtime. It does this by using the Mingw libraries and header files, which are available under the GPL. However, in order to make these libraries available to GCC, which operates thinking that it's running on a Unix system, the libraries must be stored and named in a location that GCC (or more specifically, LD, the linker) will understand.
On GNU systems, and likely on proprietary Unix systems as well (although I don't know this as a fact), a library that is to be linked dynamically will have the extension .so. A library that is to be linked statically has the extension .a. Furthermore, in either case the text "lib" is prepended to the library. When you pass a -l switch to GCC, GCC transparently passes this switch to ld, the linker. The text associated with -l will name the library. For example: If you pass -lfoobar, ld will receive it. In order to actually find the library, ld must prepend "lib" and append ".a", and then search in its known library locations. So it will search for a file called "libfoobar.a" in its known library locations.
The known library locations vary from system to system. On some GNU/Linux systems, the known library locations are stored in a special file called "ldconfig". Cygwin does not, however. It appears to know by magic where the libraries are stored. You will find them in /usr/lib, /usr/local/lib, /usr/share/lib, and ~/.lib. If you look around your Cygwin installation, you'll find a directory /usr/lib/w32api. In this directory is stored all of the Mingw libraries that allow you to link to the win32api. If you've ever worked with MSVC++, you'll probably recognize the names of these libraries. There's kernel32, odbc32, winmm, and the rest. But they're named with ld's peculiar naming convention, libkernel32.a, libodbc32.a, and libwinmm.a respectively in this example.
From the MSVC++ project file, here are the libraries that need to be linked statically for Audacity to successfully build.
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib
You can also obtain this list by modifying the Audacity Makefile to use `wx-config --static --libs` instead of `wx-config --libs` which it already uses. Currently, Audacity will not build with `wx-config --static --libs`. If you get it to work, let us know!