User:Mjb/AACGain

=Building AACGain= I'm going to try to build an SSE-optimized (Pentium III and up) version of AACGain. I'll trace my steps here.

Build instructions are in the AACGain README.

Install Visual C++ 2005

 * Download Visual C++ 2005 Express Edition from Microsoft. Install it (reboot required). It will advise you to run Windows Update. I didn't do this right away, but when I did get around to it, it didn't say I needed anything.
 * Familiarize self with  option.

Install TortoiseCVS and get the source code

 * Download TortoiseCVS. Install it, choosing to restart Explorer when prompted. I was also prompted to restart Windows for changes to CVSNT to take effect. I chose not to do that because the setup hadn't finished! I figured there was another reboot in my near future anyway.
 * Create a C:\dev folder and open it in Explorer.
 * Right-click > CVS > Preferences > Advanced > Network compression: 6 - Good.
 * Right-click > CVS Checkout.
 * In the CVSROOT field, enter
 * In the Module field, enter  and click OK. Click OK when the files are downloaded.
 * Do the same but change the Module field to  and click OK. Click OK when the files are downloaded.
 * Change the CVSROOT field to, the Module field to  , and under the Revision tab, Files at certain time, enter   as the Date/time of files to get. Click OK. Click OK when the files are downloaded.
 * Change the CVSROOT field to, the Module field to  , and under the Revision tab, Files at certain time, enter   as the Date/time of files to get. Click OK. Click OK when the files are downloaded.

Install the C libraries

 * The Microsoft Platform SDK is required. There are instructions for setting up Visual C++ Express to work with the SDK, but they tell you to get the latest version: Windows Server 2003 R2 SDK - March 2006 Edition. This can build Win2K apps but apparently doesn't run on Win2K, itself. Since I'm doing the build on Win2K, I'll download and run the older version's installer: Windows Server 2003 SP1 Platform SDK - April 2005 Edition (PSDK-x86.exe). Do a Typical Install to drive C.

Configure Visual C++ to work with the SDK

 * Step 3 of the Visual C++ / Platform SDK instructions says to update the VC directories (which are under Tools > Options > Projects and Solutions > VC++ Directories), but apparently this is not necessary if the April 2005 edition of the SDK was installed; it installs in the normal location expected by Visual C++ . It is important to do this, but to make sure to add the right directory names for your SDK. I added these values:
 * Under Executables, add
 * Under Includes, add
 * Under Libraries, add

Open the solution

 * In Visual C++, open (e.g. by just double-clicking the .sln file in Explorer).
 * You'll be prompted to allow the solution to be converted to an updated format. The files that will be updated are: aacgain.vcproj, libfaad.vcproj, libmissing.vcproj, libmp4v2.vcproj, and mp3gain.vcproj. One of them will have some warnings in the conversion report:
 * Conversion Issues - ..\faad2\libfaad\libfaad.vcproj:
 * Visual C++ now supports a secure version of the C Runtime Library. Use of this library is turned on by default. You may see some warnings about deprecated functions when you build your project. It is advised that you correct these warnings, in order to make your code more secure.
 * The C/C++ compiler default settings have been modified to be more compliant with ISO Standard C++. Included in those changes are enforcing Standard C++ for loop scoping and supporting wchar_t as a native type. These changes may cause existing code to no longer compile without changes to the code or the compiler options with which it is built. 
 * Project file successfully backed up as 'C:\dev\faad2\libfaad\libfaad.vcproj.7.10.old'.
 * Project upgraded successfully.
 * The C/C++ compiler switch /YX is lo longer supported. /YX has been removed from your project settings.
 * Due to the requirement that Visual C++ projects produce an embedded (by default) Windows SxS manifest, manifest files in the project are automatically excluded from building with the Manifest Tool. It is recommended that the dependency information contained in any manifest files be converted to "#pragma comment(linker," ")" in a header file that is included from your source code. If your project already embeds a manifest in the RT_MANIFEST resource section through a resource (.rc) file, the line will need to be commented out before the project will build correctly.
 * Due to a conformance change in the C++ compiler, code change may be required before your project will build without errors. Previous versions of the C++ compiler allowed specification of member function pointers by member function name (e.g. MemberFunctionName). The C++ standard requires a fully qualified name with the use of the address-of operator (e.g. &ClassName::MemberFunctionName). If your project contains forms or controls used in the Windows Forms Designer, you may have to change code in InitializeComponent because the designer generated code used the non-conformant syntax in delegate construction (used in event handlers).
 * At this point, the AACGain README says I should have 5 projects, the last one being "mp3gainlib". Mine is called just "mp3gain". I hope that's OK.

Update certain project properties

 * In the Solution Explorer pane, right-click on libfaad > Properties > Configuration Properties > C/C++ > Code Generation, and change Runtime Library value to "Multi-threaded (/MT)" and click Apply.
 * Up a level, under Optimization, change the Whole Program Optimization value to "Enable link-time code generation (/GL)" and click OK.
 * In the Solution Explorer pane, right-click on libmissing > Properties > Configuration Properties > C/C++ > Code Generation, and change Runtime Library value to "Multi-threaded (/MT)" and click Apply.
 * Up a level, under General, change the Additional Include Directories value to "..\..\include" and click OK.
 * In the Solution Explorer pane, right-click on libmp4v2 > Properties > Configuration Properties > C/C++ > Code Generation, and change Runtime Library value to "Multi-threaded (/MT)" and click Apply.
 * Up a level, under General, change the Additional Include Directories value to "..\..\include" and click OK.
 * Shift-Ctrl-S to Save All seems like a good idea here.

Attempt build

 * F7. Look at the failures! Oh no! What did I miss?
 * Well, those VC/SDK instructions steps 4 and 5. I'll try that:
 * In C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults\corewin_express.vsprops, change AdditionalDependencies="kernel32.lib" to AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib".
 * In C:\Program Files\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\1033\AppSettings.htm, comment out (with "//") lines 441-444.
 * Restart Visual C++ and click aacgain (under Recent Projects).
 * F7. Results are not really any better: mostly the same failures (though it's a slightly shorter list)
 * Fix the SDK Bin/Include/Lib locations in Visual C++ Options.
 * F7. Results are much better, but still have some errors: 3 down, 2 to go
 * Change newlines in C:\dev\mp3gain\mp3gain.c to PC format.
 * F7. afxres.h can't be found. Also, bad command line. Why debug builds?
 * Add C:\Program Files\Microsoft Platform SDK\Include\mfc to Includes path.
 * Set aacain and mp3gain projects to do a "Multi-threaded (/MT)" build.
 * Save all. Save.
 * F7. 2 more errors.
 * Right-click on Solution 'aacgain' in Solution Explorer pane. Go to Configuration Manager. Select Release build.
 * In project properties for each project, set Configuration value to Release. This shows you the values for a release build. Oops. I had changed the values for Debug only.
 * Re-set Configuration Properties > Code Generation > Runtime Library values as directed previously.
 * F7. Success, maybe!
 * Test it out. Seems to work, and for some reason is faster than the semi-official build!

Build optimized

 * Create a new configuration: Release-SSE.
 * In each project's properties, set /arch:SSE.
 * Save all.
 * F7. no errors, but no .exe! Warnings are all the same as for previous build.
 * Clean solution.
 * F7. Same result.
 * Remove /arch:SSE from libfaad.
 * F7. Same result.
 * Remove /arch:SSE from all projects. Clean solution.
 * F7. Same result. WTF?!
 * Restored /arch:SSE to all, then went into Release-SSE config and set all projects to use their Release configs. Clean solution.
 * F7. Build hung at atom_avc1.cpp (libmp4v2). WTF?
 * Kill process from Task Manager. Try again.
 * Remove /arch:SSE from Release configs of all projects. Duh.
 * F7. Success. C:\dev\aacgain\release\aacgain.exe created.
 * Go through all Release-SSE configs and change Release directory references to Release-SSE.
 * Set aacgain and mp3gain to use Release-SSE configs.
 * F7. Success. C:\dev\aacgain\release-sse\aacgain.exe created. No faster than the other.
 * Set all other projects to use Release-SSE configs. Clean solution.
 * F7. Success. C:\dev\aacgain\release-sse\aacgain.exe created. No faster than the other.