Building codec2 for Windows using Cmake and MinGW
I want to build and use codec2 library in my Qt application for Windows. Codec2 is incredible library for speech processing it can encode speech from 3200 up to 700 bit/s. Amazing! Let's play with it!
So I need to do:
- build codec2 for Windows
- write Qt wrappers for codec2 library;
- write application able to use codec2 with QAudio sub-system.
This post will explain how to do first step - build codec2 for windows using CMake and MinGW
Info (from Wikipedia - codec2):
Codec2 is a low-bitrate speech audio codec (speech coding) that is patent free and open source. Codec2 compresses speech using sinusoidal coding, a method specialized for human speech. Bit rates of 3200 to 700 bit/s have been successfully created. Codec2 was designed to be used for amateur radio and other high compression voice applications.
You need to:
- download and install mingw32 (I prefer GUI installer), you can find it here http://www.mingw.org
- download and install CMake (you can find it here http://www.cmake.org/ or you can use direct link https://cmake.org/files/v3.7/cmake-3.7.1-win32-x86.msi)
- clone or download codec2 sources from GitHub https://github.com/freedv/codec2 or download them directly from Rovetel http://files.freedv.org/codec2
- You need add your mingw directory to your system level PATH
- I have MinGW installed to the d:\mingw (and this directory in my system PATH);
- CMake installed to the C:\Program Files\CMake\
Then you need unpack codec2 sources and go to this directory. In my case it will be codec2-master folder.
Going go directory with sources (in command line)
> cd codec2-master
Making directory for binaries:
> mkdir build_windows
Calling CMake (and specifying scenario and path compiler names). Warning! Pay attention to two dots ('.' symbol) at the commands end:
> d:\Program Files\CMake\bin\cmake.exe" -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER=mingw32-g++.exe -D CMAKE_MAKE_PROGRAM=mingw32-make.exe ..
Compiling using MinGW
If everything was made right, you can find libcodec2.dll and libcodec2.dll.a files inside build_windows/src directory
Now we have all needful files:
This files is our target and we will use them at our next steps playing with Qt and codec2.
Note: if you need this files in binary form - feel free to contact with me, I will make them accessible.
UPD1: you can find more here http://bohdan-danishevsky.blogspot.com/2016/12/qt-wrappers-for-codec2-library.html