Jul 18, 2014

Compile QXmpp in Windows with full support

People keep asking me about how to compile my VoipTest example in Windows, even when they know I'm GNU/Linux only guy. Many people complains that they can hear the audio in VoipTest, but they doesn't receives the video signal, this occurs because they doesn't not compiles QXmpp with Speex, Opus, Theora and Vpx codecs.
So, in this post I will teach you how to compile QXmpp with full codec support in Windows :)

Install Npackd

Fist at all, you must download and install Npackd from here. Npackd is like our package manager for GNU/Linux.
Then configure the repositories from Package -> Preferences, to point to:
https://npackd.appspot.com/rep/xml?tag=stable
https://npackd.appspot.com/rep/xml?tag=libs

Install MSYS

From Npackd, install the item: MinGW installation Manager Setup Tool. Then open MinGW Installer ans install:
mingw-developer-toolkit
mingw-base
mingw-gcc-g++
msys-base
And from All Packages, install:
msys-unzip
msys-wget
When the installation is done, go to C:\MinGW\msys\1.0\etc and edit the file fstab. Put the following content inside.
#Win32_Path                       Mount_Point
C:\MinGW                          /mingw
C:\Users\YourUser\Documents       /documents
C:\Users\YourUser\Desktop         /desktop
C:\Qt\Qt5.6.0\5.6\mingw49_32\bin  /qttools
This file will add some shortcuts to our cd command. When you write cd /documents, you will be changing your current directory to C:\Users\User\Documents, the MSYS's fstab creates *nix like aliases to Windows paths.
Now create a direct access of C:\MinGW\msys\1.0\msys.bat to your desktop and open it.

Create the compile script

This is the main step, create a file (with the .sh extension) in, for example, your /documents directory, with the following content:
#!/bin/sh
 
qxmppVersion=0.9.3
yasmVersion=1.3.0
oggVersion=1.3.2
speexVersion=1.2rc2
opusVersion=1.1.2
theoraVersion=1.1.1
vpxVersion=1.5.0
mainPath="$PWD"
 
function getYasm()
{
    wget -c http://www.tortall.net/projects/yasm/releases/yasm-$yasmVersion-win32.exe
    ln -s yasm-$yasmVersion-win32.exe yasm.exe
}
 
function compileOgg()
{
    wget -c http://downloads.xiph.org/releases/ogg/libogg-$oggVersion.zip
    unzip -u libogg-$oggVersion.zip
    cd libogg-$oggVersion
 
    ./configure --prefix="$mainPath/win32" --disable-shared
 
    make
    make install
}
 
function compileSpeex()
{
    wget -c http://downloads.xiph.org/releases/speex/speex-$speexVersion.tar.gz
    tar -zxvf speex-$speexVersion.tar.gz
    cd speex-$speexVersion
 
    ./configure --prefix="$mainPath/win32" --disable-shared --with-ogg-libraries="$mainPath/win32/lib" --with-ogg-includes="$mainPath/win32/include" --disable-oggtest
 
    make CFLAGS="-I$mainPath/win32/include -L$mainPath/win32/lib"
    make install
}

function compileOpus()
{
    wget -c http://downloads.us.xiph.org/releases/opus/opus-$opusVersion.tar.gz
    tar -zxvf opus-$opusVersion.tar.gz
    cd opus-$opusVersion
 
    ./configure --prefix="$mainPath/win32" --enable-shared=no --disable-doc --disable-extra-programs

    make CFLAGS="-I$mainPath/win32/include -L$mainPath/win32/lib"
    make install
}
 
function compileTheora()
{
    wget -c http://downloads.xiph.org/releases/theora/libtheora-$theoraVersion.zip
    unzip -u libtheora-$theoraVersion.zip
    cd libtheora-$theoraVersion
 
    ./configure --prefix="$mainPath/win32" --disable-shared --with-ogg-libraries="$mainPath/win32/lib" --with-ogg-includes="$mainPath/win32/include" --disable-encode --disable-oggtest --disable-vorbistest --disable-sdltest --disable-examples --without-vorbis
 
    make CFLAGS="-I$mainPath/win32/include -L$mainPath/win32/lib"
    make install
}
 
function compileVpx()
{
    fileName=libvpx-$vpxVersion.tar.gz
    wget -c --no-check-certificate -O $fileName https://github.com/webmproject/libvpx/archive/v$vpxVersion.tar.gz
    tar -zxvf $fileName
    cd libvpx-$vpxVersion
 
    ./configure --prefix="$mainPath/win32" --disable-shared --disable-unit-tests --disable-examples --disable-docs
 
    make
    make install
}
 
function compileQXmpp()
{
    fileName=qxmpp-$qxmppVersion.tar.gz
    wget -c --no-check-certificate -O $fileName https://github.com/qxmpp-project/qxmpp/archive/v$qxmppVersion.tar.gz
    tar -zxvf $fileName
    cd qxmpp-$qxmppVersion
 
    /qttools/qmake QXMPP_LIBRARY_TYPE=staticlib QXMPP_USE_SPEEX=1 QXMPP_USE_OPUS=1 QXMPP_USE_THEORA=1 QXMPP_USE_VPX=1 PREFIX="$mainPath/win32"
 
    mingw32-make CXXFLAGS="-I$mainPath/win32/include -L$mainPath/win32/lib"
    mingw32-make install
}
 
export PATH="$mainPath:$PATH"
 
getYasm
compileOgg
cd "$mainPath"
compileSpeex
cd "$mainPath"
compileOpus
cd "$mainPath"
compileTheora
cd "$mainPath"
compileVpx
cd "$mainPath"
compileQXmpp
Then, in MSYS, execute the script as:
chmod +x buildqxmpp.sh
./buildqxmpp.sh
When build finishes, you will have all required files inside the win32 folder:
win32/include/qxmpp/*.h
win32/lib/libqxmpp.a
Finally you can link your project to QXmpp by writing (inside you QMake project file):
INCLUDEPATH += win32/include/qxmpp
LIBS += -Lwin32/lib -lqxmpp
Thats all. I've tested it in Windows 8.1, so I can guarantee that this compiling method is actually working :)
NOTE: As some readers commented,
if the script never finish compiling, replace make with mingw32-makethere seems to be a conflict between the make provided by Qt and the make provided by MSYS, it runs well the first time, and fails with the successive builds, I have updated the script above.

25 comments:

  1. this
    wget -c --no-check-certificate https://github.com/qxmpp-project/qxmpp/archive/v$qxmppVersion.zip
    gives "v0.8.0" file as the result.


    "make" continues hour+ already. Is it OK?

    ReplyDelete
    Replies
    1. Yes, it's ok, I've tested it in Windows 8, so it works for sure :)

      Delete
    2. honestly it was continues forever with no effect and same string "... -o Makefile qxmpp.pro"
      changing make to mingw32-make solved problem

      Delete
    3. I am having the same problem. I let it run over the whole weekend and it never finished. Do I have to recompile everything (Ogg, Speex, Theora, Vpx) using mingw32-make or will it work when I only compile qxmpp using mingw32-make and the rest with make?

      Delete
    4. If mingw32-make works for you, thats ok. I have no that bug, so I have not idea how it look like.

      Delete
    5. This comment has been removed by the author.

      Delete
  2. Anyway, as i've asked at github: guess i have job offer for You, can we diiscuss over skype "fedormobile" / ffl.public at gmail.com if You're interested?

    ReplyDelete
  3. Hi! I got this script working on release, but I would like to make it work on debug builds too. I tried adding CONFIG+=debug to create the debug libraries -lqxmpp_d (libqxmpp_d.a) and it did, but when I added this library on debug build in .pro -file it was not enough, as it said "could not find -lqxmpp_d0". Building the qxmpp libraries with Qt does create -lqxmpp_d0 (libqxmpp_d0.a), but i would need to figure out how to build vpx and others in Qt pro -files, while this script already does it. Would you happend to know what this libqxmpp_d0.a file is and if I can build it on console?

    ReplyDelete
    Replies
    1. This happens in the last step when you are installing the QXmpp libraries, right? I have tested today, in the qxmpp.pro file, just comment the line that says:

      SUBDIRS += tests examples

      Delete
    2. That... suggestion did not really do what I asked. So you're saying that you were able to build libqxmpp_d0.a, not just libqxmpp_d.a, when compiling with your script? Because that's what I don't understand why Qt keeps looking for lqxmpp_d0 when it has lqxmpp_d for debugging. And yes, this is about the last step when I'm trying to install QXmpp libraries. The process goes smooth, but when I try to add the compiled library to a Qt project it gives me the mentioned error.

      Delete
    3. Can you copy the error or give me a capture? be cause I have no such error, it only ask me for -lvpx, -logg, and so on, but it never ask me for such -lqxmpp_d0 library.

      Delete
    4. http://picpaste.com/pics/process.1425639102.jpg <-- here I took a screenshot of all the relative information. At #1 I make sure the library files are created (libqxmpp.a and libqxmpp_d.a). Then I add them to Qt project pro-file (I'm using GuiClient from QXmpp as my testing ground). It builds fine with release, but not with debugging because it keeps insisting on libqxmpp_d0.a. I have included the outputs from issues and compiler. I found out I can easily compile both release and debug libraries when I use 'CONFIG += build_all' with qmake.

      Delete
    5. Ok, I have tried it, I commented the line:

      include(../examples.pri)

      This removed the libqxmpp_d0.a conflict. then added the lines to my static qxmpp:

      INCLUDEPATH += C:\Users\MyUser\Desktop\win32\include\qxmpp
      win32: CONFIG(release, debug|release): LIBS += -LC:\Users\MyUser\Desktop\win32\lib -lqxmpp
      else: win32: CONFIG(debug, debug|release): LIBS += -LC:\Users\MyUser\Desktop\win32\lib -lqxmpp_d


      but it give me linking errors with undefined symbols. At this point, I think that will be better to make this question in the QXmpp issues page.

      Delete
  4. Hi ,
    I have a proble when I execute the script . I have a lots of error like :
    wget : command not found
    make : command not found
    ./configure : No such file or directory

    I work with QT 5.4 on Windows 8.1

    Someone can help me ? Thanks a lot

    ReplyDelete
    Replies
    1. Did you installed this packages:

      mingw-developer-toolkit
      mingw-base
      mingw-gcc-g++
      msys-base
      msys-unzip
      msys-wget

      Try installing them with:

      mingw-get install mingw-developer-toolkit mingw-base mingw-gcc-g++ msys-base msys-unzip msys-wget

      And run the script again.

      Delete
    2. i get this error
      can not access 'buildqxmpp.sh': no such a directory
      please any one help me

      Delete
    3. Hi, you must switch the directory where the buildqxmpp.sh is located with cd, here is a guide for using that commands:

      https://www.digitalocean.com/community/tutorials/how-to-use-cd-pwd-and-ls-to-explore-the-file-system-on-a-linux-server#finding-out-where-you-are-with-pwd

      Alternatively, you forgot to make the script executable with chmod, or did you not give that name to the script.

      Delete
    4. qttools/qmake no such file or directory
      mingw32-make command not found

      Delete
    5. I am getting this can any one help me??
      Could not start process "C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\bin\qmake.exe" C:\Users\MEET\Downloads\qxmpp-master\qxmpp-master\qxmpp.pro -r -spec win32-msvc2012 "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug"
      Error while building/deploying project qxmpp (kit: Desktop Qt 5.2.1 MSVC2012 64bit)
      When executing step 'qmake'

      Delete
    6. I've updated the post, please update to the latest Qt version, and make sure fstab points to the right path. Also, download the MinGW installer.

      Qt 5.6.0 for Windows 32-bit (MinGW 4.9.2, 1.0 GB)

      Delete
    7. I am still getting the same error as above

      Delete
    8. It's a problem with your system then, this tutorial is for MinGW only, if you want to compile QXmpp for MSVC you must find your way, sorry.

      ### EDIT ###

      Ultimately, try setting MinGW as default compiler from Qt Creator > Tools > Options > Build & Run > Kits > Make Default. If that doesn't works, sorry, i'm run out of ideas. But stay in mind that MinGW and MSVC libraries are not compatible btw, if you still want to compile QXmpp for MSVC, you must find a way of compiling QXmpp + the other codecs libraries. If you find a way, let it know in the discussion group.

      Delete