vgmstream/doc/BUILD.md

275 lines
13 KiB
Markdown
Raw Normal View History

# vgmstream build help
2016-12-11 13:26:30 +01:00
2019-03-21 04:42:16 +01:00
If you wish to use CMake, see [CMAKE.md](CMAKE.md).
2016-12-11 13:26:30 +01:00
## Compilation requirements
2017-05-01 17:33:22 +02:00
**GCC / Make**: In Windows this means one of these two somewhere in PATH:
2016-12-11 13:26:30 +01:00
- MinGW-w64 (32bit version): https://sourceforge.net/projects/mingw-w64/
2017-05-01 17:33:22 +02:00
- Use this for easier standalone executables
- Latest online installer with any config should work (for example: gcc-7.2.0, i686, win32, sjlj).
2016-12-11 13:26:30 +01:00
- MSYS2 with the MinGW-w64_shell (32bit) package: https://msys2.github.io/
2017-01-22 12:29:29 +01:00
**MSVC / Visual Studio**: Microsoft's Visual C++ and MSBuild, bundled in either:
- Visual Studio (2015/2017/latest): https://www.visualstudio.com/downloads/
2017-12-24 01:30:57 +01:00
- Visual Studio Community should work (free, but must register after trial period)
2017-01-22 12:29:29 +01:00
- Visual C++ Build Tools (no IDE): http://landinghub.visualstudio.com/visual-cpp-build-tools
2016-12-11 13:26:30 +01:00
**Git**: optional, to generate version numbers:
- Git for Windows: https://git-scm.com/download/win
2018-09-12 22:59:49 +02:00
**autotools**: optional, indirectly used by some libs.
- For Windows you must include GCC and Linux's sh tool in some form in PATH.
- The simplest would be installing MinGW-w64 for GCC.exe and Git for sh.exe, and making PATH point their bin dir.
- ex. `C:/i686-7.1.0-win32-sjlj-rt_v5-rev2/mingw32/bin` and `C:/Git/bin`
- Both must be installed/copied in a dir without spaces
2016-12-11 13:26:30 +01:00
## Compiling modules
2017-12-28 22:30:45 +01:00
### CLI (test.exe/vgmstream-cli) / Winamp plugin (in_vgmstream) / XMPlay plugin (xmp-vgmstream)
2016-12-11 13:26:30 +01:00
**With GCC**: use the *./Makefile* in the root folder, see inside for options. For compilation flags check the *Makefile* in each folder.
You may need to manually rebuild if you change a *.h* file (use *make clean*).
2016-12-11 13:26:30 +01:00
In Linux, Makefiles can be used to cross-compile with the MingW headers, but may not be updated to generate native code at the moment. It should be fixable with some effort. Autotools should build it as vgmstream-cli instead (see the Audacious section). Some Linux distributions like Arch Linux include pre-patched vgmstream with most libraries, you may want that instead (see: https://aur.archlinux.org/packages/vgmstream-kode54-git/).
2016-12-11 13:26:30 +01:00
2017-12-28 22:30:45 +01:00
Windows CMD example:
2016-12-11 13:26:30 +01:00
```
2017-01-22 12:29:29 +01:00
prompt $P$G$_$S
set PATH=C:\Program Files (x86)\Git\usr\bin;%PATH%
set PATH=C:\Program Files (x86)\mingw-w64\i686-5.4.0-win32-sjlj-rt_v5-rev0\mingw32\bin;%PATH%
2016-12-11 13:26:30 +01:00
cd vgmstream
mingw32-make.exe vgmstream_cli -f Makefile ^
VGM_ENABLE_FFMPEG=1 ^
2016-12-11 13:26:30 +01:00
SHELL=sh.exe CC=gcc.exe AR=ar.exe STRIP=strip.exe DLLTOOL=dlltool.exe WINDRES=windres.exe
```
2018-01-20 05:24:33 +01:00
**With MSVC**: To build in Visual Studio, run *./init-build.bat*, open *./vgmstream_full.sln* and compile. To build from the command line, run *./build.bat*.
The build script will automatically handle obtaining dependencies and making the project changes listed in the foobar2000 section (you may need to get some PowerShell .NET packages).
You can also call MSBuild directly in the command line (see the foobar2000 section for dependencies and examples)
2017-05-01 17:33:22 +02:00
### foobar2000 plugin (foo\_input\_vgmstream)
2016-12-11 13:26:30 +01:00
Requires MSVC (foobar/SDK only links to MSVC C++ DLLs) and these dependencies:
2018-01-21 01:47:17 +01:00
- foobar2000 SDK (2018), in *(vgmstream)/dependencies/foobar/*: http://www.foobar2000.org/SDK
2018-01-20 05:24:33 +01:00
- FDK-AAC, in *(vgmstream)/dependencies/fdk-aac/*: https://github.com/kode54/fdk-aac
- QAAC, in *(vgmstream)/dependencies/qaac/*: https://github.com/kode54/qaac
- WTL (if needed), in *(vgmstream)/dependencies/WTL/*: http://wtl.sourceforge.net/
2018-01-20 05:24:33 +01:00
The following project modifications are required:
2017-01-15 23:10:43 +01:00
- For *foobar2000_ATL_helpers* add *../../../WTL/Include* to the compilers's *additional includes*
FDK-AAC/QAAC can be safely disabled by removing *VGM_USE_MP4V2* and *VGM_USE_FDKAAC* in the compiler/linker options and the project dependencies, as FFmpeg is used instead to support their codecs.
You can also manually use the command line to compile with MSBuild, if you don't want to touch the .vcxproj files, register VS after trial, get PowerShell dependencies for the build script, or only have VC++/MSBuild tools.
Windows CMD example for foobar2000:
```
prompt $P$G$_$S
set PATH=C:\Program Files (x86)\Git\usr\bin;%PATH%
set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
2016-12-11 13:26:30 +01:00
cd vgmstream
set CL=/I"C:\projects\WTL\Include"
set LINK="C:\projects\foobar\foobar2000\shared\shared.lib"
msbuild fb2k/foo_input_vgmstream.vcxproj ^
/t:Clean
msbuild fb2k/foo_input_vgmstream.vcxproj ^
/t:Build ^
/p:Platform=Win32 ^
/p:PlatformToolset=v140 ^
/p:Configuration=Release ^
/p:DependenciesDir=../..
```
2017-01-22 12:29:29 +01:00
### Audacious plugin
2017-12-24 01:30:57 +01:00
Requires the dev version of Audacious (and dependencies), automake/autoconf, and gcc/make (C++11). It must be compiled and installed into Audacious, where it should appear in the plugin list as "vgmstream".
2017-01-22 12:29:29 +01:00
2017-12-24 01:30:57 +01:00
The plugin needs Audacious 3.5 or higher. New Audacious releases can break plugin compatibility so it may not work with the latest version unless adapted first.
2017-05-01 17:33:22 +02:00
2018-12-04 00:00:22 +01:00
libvorbis and libmpg123 will be used if found, while FFmpeg and other external libraries aren't enabled at the moment, thus some formats won't work (build scripts need to be fixed).
2017-05-01 17:33:22 +02:00
Windows builds aren't supported at the moment (should be possible but there are complex dependency chains).
Terminal example, assuming a Ubuntu-based Linux distribution:
```
2017-12-28 22:30:45 +01:00
# build requirements
2017-05-01 17:33:22 +02:00
sudo apt-get update
sudo apt-get install gcc g++ make
sudo apt-get install autoconf automake libtool
2017-12-28 22:30:45 +01:00
sudo apt-get install git
# vgmstream dependencies
sudo apt-get install libmpg123-dev libvorbis-dev
# Audacious player and dependencies
sudo apt-get install audacious
sudo apt-get install audacious-dev libglib2.0-dev libgtk2.0-dev libpango1.0-dev
2017-05-01 17:33:22 +02:00
2017-12-28 22:30:45 +01:00
# check Audacious version >= 3.5
2017-05-01 17:33:22 +02:00
pkg-config --modversion audacious
2017-12-28 22:30:45 +01:00
# build
2017-05-01 17:33:22 +02:00
git clone https://github.com/kode54/vgmstream
cd vgmstream
./bootstrap
./configure
2018-01-05 00:57:00 +01:00
make -f Makefile.autotools
2017-05-01 17:33:22 +02:00
2018-12-04 00:00:22 +01:00
# copy to audacious plugins and update global libvgmstream.so.0 refs
2018-01-05 00:57:00 +01:00
sudo make -f Makefile.autotools install
2018-12-04 00:00:22 +01:00
sudo ldconfig
2017-05-01 17:33:22 +02:00
2018-12-04 00:00:22 +01:00
# start audacious in verbose mode to check if it was installed correctly
audacious -V
# uninstall if needed
sudo make -f Makefile.autotools uninstall
2017-05-01 17:33:22 +02:00
2017-12-28 22:30:45 +01:00
# optional post-cleanup
2018-01-05 00:57:00 +01:00
make -f Makefile.autotools clean
2017-05-01 17:33:22 +02:00
find . -name ".deps" -type d -exec rm -r "{}" \;
./unbootstrap
## WARNING, removes *all* untracked files not in .gitignore
git clean -fd
```
2017-01-22 12:29:29 +01:00
2018-09-12 22:59:49 +02:00
### vgmstream123 player
2018-01-05 00:57:00 +01:00
Should be buildable with Autotools, much like the Audacious plugin, though requires libao (libao-dev).
2017-12-28 22:30:45 +01:00
2018-01-21 01:47:17 +01:00
Windows builds are possible with libao.dll and includes, but some features are disabled.
2018-09-12 22:59:49 +02:00
2018-12-15 12:36:48 +01:00
libao is licensed under the GPL v2 or later.
2018-09-12 22:59:49 +02:00
## External libraries
Support for some codecs is done with external libs, instead of copying their code in vgmstream. There are various reasons for this:
- each lib may have complex or conflicting ways to compile that aren't simple to duplicate
- their sources can be quite big and undesirable to include in full
- libs usually only compile with either GCC or MSVC, while vgmstream supports both compilers, so linking to the generated binary is much easier
- not all licenses used by libs may allow to copy their code
- simplifies maintenance and updating
They are compiled in their own sources, and the resulting binary is linked by vgmstream using a few of their symbols.
Currently only Windows builds can use external libraries, as vgmstream only includes generated 32-bit DLLs, but it should be fixable for others systems with some effort (libs are enabled on compile time). Ideally vgmstream could use libs compiled as static code (thus eliminating the need of DLLs), but involves a bunch of changes.
Below is a quick explanation of each library and how to compile binaries from them. Unless mentioned, their latest version should be ok to use, though included DLLs may be a bit older.
### libvorbis
Adds support for Vorbis (inside Ogg and custom containers).
- Source: http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.zip
- DLL: `libvorbis.dll`
2018-12-15 12:36:48 +01:00
- licensed under the 3-clause BSD license.
2018-09-12 22:59:49 +02:00
Should be buildable with MSVC (in /win32 dir are .sln files) or autotools (use `autogen.sh`).
### mpg123
Adds support for MPEG (MP1/MP2/MP3).
- Source: https://sourceforge.net/projects/mpg123/files/mpg123/1.25.10/
- Builds: http://www.mpg123.de/download/win32/1.25.10/
- DLL: `libmpg123-0.dll`
2018-12-15 12:36:48 +01:00
- licensed under the LGPL v2.1
2018-09-12 22:59:49 +02:00
Must use autotools (sh configure, make, make install), though some scripts simplify the process: `makedll.sh`, `windows-builds.sh`.
### libg7221_decode
Adds support for ITU-T G.722.1 annex C (standardization of Polycom Siren 14).
2018-10-04 19:43:44 +02:00
- Source: https://github.com/bnnm/vgmstream-g7221
- Alt lib (has volume problems): https://github.com/kode54/libg7221_decode
2018-12-15 12:36:48 +01:00
- licensed under the LGPL v3 (possibly invalid and Polycom's)
2018-09-12 22:59:49 +02:00
- DLL: `libg7221_decode.dll`
2018-12-15 12:36:48 +01:00
- unknown license (possibly invalid and Polycom's)
2018-09-12 22:59:49 +02:00
2018-10-04 19:43:44 +02:00
Use make `libg7221_decode.dll`.
2018-09-12 22:59:49 +02:00
### libg719_decode
Adds support for ITU-T G.719 (standardization of Polycom Siren 22).
- Source: https://github.com/kode54/libg719_decode
- DLL: `libg719_decode.dll`
2018-12-15 12:36:48 +01:00
- unknown license (possibly invalid and Polycom's)
2018-09-12 22:59:49 +02:00
Requires MSVC (use `g719.sln`).
### FFmpeg
Adds support for multiple codecs: ATRAC3, ATRAC3plus, XMA1/2, WMA v1, WMA v2, WMAPro, AAC, Bink, AC3/SPDIF, Opus, Musepack, FLAC, etc (also Vorbis and MPEG for certain cases).
- Source: https://github.com/FFmpeg/FFmpeg/
- DLLs: `avcodec-vgmstream-58.dll`, `avformat-vgmstream-58.dll`, `avutil-vgmstream-56.dll`, `swresample-vgmstream-3.dll`
2018-12-15 12:36:48 +01:00
- primarily licensed under the LGPL v2.1 or later, with portions licensed under the GPL v2
2018-09-12 22:59:49 +02:00
2018-10-04 19:43:44 +02:00
vgmstream's FFmpeg builds remove many unnecessary parts of FFmpeg to trim down its gigantic size, and are also built with the "vgmstream-" preffix (to avoid clashing with other plugins). Current options can be seen in `ffmpeg_options.txt`.
2018-09-12 22:59:49 +02:00
For GCC simply use autotools (configure, make, make install), passing to `configure` the above options.
For MSCV it can be done through a helper: https://github.com/jb-alvarado/media-autobuild_suite
2018-10-04 19:43:44 +02:00
Both may need yasm somewhere in PATH to properly compile: https://yasm.tortall.net
2018-09-12 22:59:49 +02:00
### LibAtrac9
Adds support for ATRAC9.
- Source: https://github.com/Thealexbarney/LibAtrac9
- DLL: `libatrac9.dll`
2018-12-15 12:36:48 +01:00
- licensed under the MIT license
2018-09-12 22:59:49 +02:00
Use MSCV and `libatrac9.sln`, or GCC and the Makefile included.
2018-09-12 22:59:49 +02:00
### libcelt
Adds support for FSB CELT versions 0.6.1 and 0.11.0.
- Source (0.6.1): http://downloads.us.xiph.org/releases/celt/celt-0.6.1.tar.gz
- Source (0.11.0): http://downloads.xiph.org/releases/celt/celt-0.11.0.tar.gz
- DLL: `libcelt-0061.dll`, `libcelt-0110.dll`
2018-12-15 12:36:48 +01:00
- licensed under the MIT license
2018-09-12 22:59:49 +02:00
FSB uses two incompatible, older libcelt versions. Both libraries export the same symbols so normally can't coexist together. To get them working we need to make sure symbols are renamed first. This may be solved in various ways:
- using dynamic loading (LoadLibrary) but for portability it isn't an option
- It may be possible to link+rename using .def files
- Linux/Mingw's objcopy to (supposedly) rename DLL symbols
- Use GCC's preprocessor to rename functions on compile
- Rename functions in the source code directly.
To compile we'll use autotools with GCC preprocessor renaming:
2018-09-12 22:59:49 +02:00
- in the celt-0.6.1 dir:
```
# creates Makefiles with Automake
sh.exe ./configure
# LDFLAGS are needed to create the .dll (Automake whinning)
# CFLAGS rename a few CELT functions (we don't import the rest so they won't clash)
mingw32-make.exe clean
mingw32-make.exe LDFLAGS="-no-undefined" AM_CFLAGS="-Dcelt_decode=celt_0061_decode -Dcelt_decoder_create=celt_0061_decoder_create -Dcelt_decoder_destroy=celt_0061_decoder_destroy -Dcelt_mode_create=celt_0061_mode_create -Dcelt_mode_destroy=celt_0061_mode_destroy -Dcelt_mode_info=celt_0061_mode_info"
```
- in the celt-0.11.0 dir:
```
# creates Makefiles with Automake
sh.exe ./configure
# LDFLAGS are needed to create the .dll (Automake whinning)
# CFLAGS rename a few CELT functions (notice one is different vs 0.6.1), CUSTOM_MODES is also a must.
mingw32-make.exe clean
mingw32-make.exe LDFLAGS="-no-undefined" AM_CFLAGS="-DCUSTOM_MODES=1 -Dcelt_decode=celt_0110_decode -Dcelt_decoder_create_custom=celt_0110_decoder_create_custom -Dcelt_decoder_destroy=celt_0110_decoder_destroy -Dcelt_mode_create=celt_0110_mode_create -Dcelt_mode_destroy=celt_0110_mode_destroy -Dcelt_mode_info=celt_0110_mode_info"
```
- take the .dlls from celt-x.x.x/libcelt/.libs, and rename libcelt.dll to libcelt-0061.dll and libcelt-0110.dll respectively.
- Finally the includes. libcelt gives "celt.h" "celt_types.h" "celt_header.h", but since we renamed a few functions we have a simpler custom .h with minimal renamed symbols.
2019-03-18 00:08:22 +01:00
### maiatrac3plus
This lib was used as an alternate for ATRAC3PLUS decoding. Now this is handled by FFmpeg, though some code remains for now.
It was a straight-up decompilation from Sony's libs, without any clean-up or actual reverse engineering, thus legally and morally dubious.
It doesn't do encoder delay properly, but on the other hand decoding is 100% accurate unlike FFmpeg (probably inaudible though).
So, don't use it unless you have a very good reason.