Skip to content
PantheonOfSol edited this page Oct 26, 2023 · 1 revision

Cross-compiling with MinGW32

This section explains how to cross-compile Chromaprint on Linux with MinGW32. On Ubuntu, you can install the whole MinGW32 cross-compilation environment using the mingw32 package:

$ sudo apt-get install mingw32

Before you start, you need to build FFmpeg as described here. I'll assume the directory structure is the same as in the post.

Create a file named mingw.cmake in the directory ~/code/mingw32/ with the following content:

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc /home/user/code/mingw32/install/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Now you can compile Chromaprint:

$ git clone git://github.com/lalinsky/chromaprint.git
$ cd chromaprint
$ cmake \
    -DBUILD_EXAMPLES=ON -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_TOOLCHAIN_FILE=~/code/mingw32/mingw.cmake \
    -DCMAKE_INSTALL_PREFIX=~/code/mingw32/install/ .
$ make
$ make install

Change -DBUILD_SHARED_LIBS=OFF to -DBUILD_SHARED_LIBS=ON if you want to build a DLL.

Clone this wiki locally