We're hiring!
*

Building GStreamer on Windows

Aaron Boxer avatar

Aaron Boxer
November 26, 2019

Share this post:

Given GStreamer's roots in the Linux/GTK world, Windows has seemed at times like a second-class citizen when it came to hacking GStreamer code. With the advent of meson and gst-build, however, this is no longer the case. It is now possible to set up a Windows development environment that rivals the finest Linux has to offer, with full support for Visual Studio debugging into the library.

Here's how:

Setup

We are going to use not one but two IDEs ! Vi vs EMACS people : Nothing to see here, move along.

  1. gst-build pre-requisites for Windows
  2. Visual Studio 2019 community edition
  3. Eclipse CDT (you will need to have a Java JRE/JDK installed) (optional)

I also recommend the superb Git client Git Extensions.

Important: once Git is installed, ensure that line endings are configured to core.autocrlf in your Git configuration. Otherwise, you may get Windows line endings breaking GStreamer shell scripts.

Next, we set up a few environment variables (note the backslash at the end of each path except the last one):

Environment Variable Value
SOURCE_DIR c:\\PATH\TO\YOUR\SOURCE\
GSTREAMER_1_0_ROOT_X86_64 %SOURCE_DIR%x86_64\
GST_SRC_BUILD_PATH %SOURCE_DIR%gst-build\build\subprojects\
GST_PLUGIN_PATH %GST_SRC_BUILD_PATH%gst-plugins-good;%GST_SRC_BUILD_PATH%gst-plugins-bad;%GST_SRC_BUILD_PATH%gst-plugins-base

Now, we will clone gst-build into our SOURCE_DIR directory, like so:

cd %SOURCE_DIR%
git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git

And finally we add the following entry to our PATH environment variable

%GSTREAMER_1_0_ROOT_X86_64%bin

Build

  1. Open a Visual Studio x64 command prompt:

Visual Studio 2019 \ x64 Native Tools Command Prompt

  1. Run meson on gst-build:
cd %SOURCE_DIR%gst-build
meson --prefix=%GSTREAMER_1_0_ROOT_X86_64% build

Option 1: Build with from the command line

  1. Run ninja to build gst-build
    ninja -C build

Jump to step 8.

Option 2: Build GStreamer with Eclipse

  1. Launch Eclipse from the prompt:

C:\\PATH\TO\ECLIPSE\eclipse.exe

  1. Under the Eclipse File \ Import menu, choose import C++\Existing code as Makefile Project and select the %SOURCE_DIR%gst-build folder. You now have a fully-indexed, fully searchable project containing GStreamer code for base, plugins etc. Since gst-build is a big project, and Eclipse uses a lot of resources, we can filter out the build folder from the project by:

    1. typing Alt Enter to open the project Properties

    2. Under Resource \ Resource Filters, add a filter to exclude the build folder (choose the Project Relative Path setting)

  2. Eclipse by default does not save files before building. Under Windows \ Preferences \ General \ Workspace \ Build. select Save automatically before build

  3. Right click on the gst-build project, select Properties \ C++ Build, un-check Use default build command and enter ninja -C build as the build command

  4. Ctrl + B to build GStreamer

  5. When the build is complete, return to the x64 command prompt and run ninja -C build install to install GStreamer to GSTREAMER_1_0_ROOT_X86_64

Hack

  1. Open your project in Visual Studio. Your compile and link settings should use the GSTREAMER_1_0_ROOT_X86_64 environment variable to ensure you are linking to the gst-build version of GStreamer

  2. To set breakpoints in GStreamer, open the file from the appropriate sub-project inside GST_SRC_BUILD_PATH and set the breakpoint

  3. To modify GStreamer code, edit the code and build in Eclipse (or your favorite editor) - your Visual Studio project will automagically pick up the changes when it next runs. Don't forget to run the ninja -C build install step.

Push

  1. Inside GST_SRC_BUILD_PATH, the Git repositories can be modified to point to different branches. The only issue here is when executing ninja -C build update, which will stop on the modified repositories

  2. The only tool missing on Windows is gst-indent. To indent new code, we need to:

    1. Install Windows Subsystem for Linux (WSL), with Ubuntu 18.04 and GNU indent 2.2.11
    2. Open WSL
    3. sudo apt install git autoconf autopoint libtool make texi2html
    4. mkdir src && cd src
    5. wget https://ftp.gnu.org/gnu/indent/indent-2.2.11.tar.gz
    6. tar xvzf indent-2.2.11.tar.gz
    7. cd indent-2.2.11 && ./configure
    8. make && sudo make install

Now we can indent new code in the Ubuntu terminal like so:

/mnt/c/PATH/TO/SOURCE/gst-build/subprojects/gstreamer/tools/gst-indent /mnt/c/PATH/TO/FILE.c

Finally, we take the potentially dangerous step of removing the gst-indent pre-commit hook from the GStreamer sub-project we are working on:

  1. cd %SOURCE_DIR%gst-build\subprojects\SOME_GST_SUBPROJECT\.git\hooks
  2. del pre-commit

We must now be careful to remember to run gst-indent from the Ubuntu terminal before committing.

Now sit back and give yourself a big high-five !

If you have any questions about GStreamer on Windows or any other platform, please contact us.

Comments (14)

  1. yair:
    Nov 27, 2019 at 07:50 AM

    thank you, excellent timing.
    just had to do a couple of things to get it working for me.
    1. disable MSDK -Dgst-plugins-bad:msdk=disabled
    (still haven't installed the media SDK on my system and ninja was complaining on libmfx.lib missing)
    2. libxml2 was not passing
    FAILED: subprojects/libxml2-2.9.7/
    2a. had to disable GES in meson_options.txt
    2b. remove subprojects/libxml.wrap

    probably better way to do all this...

    Reply to this comment

    Reply to this comment

    1. Aaron Boxer:
      Nov 27, 2019 at 05:39 PM

      Hi Yair,
      Thanks for your feedback! For the MSDK issue, I do get an error posted about missing the Intel Media SDK,
      but it doesn't prevent building GStreamer or running any pipelines. And I didn't see the GES or libxml
      issues you mentioned, perhaps this is a conflict from a previous GStreamer binary install ?
      Cheers,
      Aaron

      Reply to this comment

      Reply to this comment

      1. yair:
        Nov 29, 2019 at 10:11 AM

        didn't mention i'm running on ubuntu 18LTS.
        the further i go into gst i feel a docker approach for building is the best solution.
        i started digging into gst-ci but im missing some knowhow on best method to run it locally.
        anyways, your article was just in time for me. i'm a happy reader.

        Reply to this comment

        Reply to this comment

        1. Aaron Boxer:
          Dec 02, 2019 at 01:47 PM

          Yes, docker would be great - you might want to open an issue for this on the GStreamer Gitlab site.
          I'm glad you found this post helpful !

          Reply to this comment

          Reply to this comment

  2. FT:
    Dec 28, 2019 at 10:22 AM

    Hi, Aaron! Thanks for this very useful post.

    I've successfully built the current gst-build master in a Win10 VM following mostly your instructions. I needed a few changes, though, to make it work:
    1. I copied python.exe to python3.exe, as some modules were looking for python3 and failing to build if not found.
    2. I also added pkg-config lite (https://sourceforge.net/projects/pkgconfiglite/) to my path as a lot of references were made during installation that it was missing. This might not be absolutely necessary.

    Reply to this comment

    Reply to this comment

    1. Aaron Boxer:
      Jan 07, 2020 at 03:14 PM

      Thanks for the feedback! I'm not sure how your environment is configured, but I don't think you should need to rename python or use pkg-config
      for the build. pkg-config is needed when building other components on top of gst-build, so that they all use the same glib version.

      Reply to this comment

      Reply to this comment

  3. FT:
    Dec 28, 2019 at 12:59 PM

    While the build process did not quit with an error, I noticed that many components were not built even from gst-plugins-base, such as gstogg.dll. I see no mentioning of the ogg component in the meson-log.txt, though I suspect that a dependency was missing. There's a line in the meson.build in that folder that depends on 'ogg' (gst-build\gst-plugins-base\ext\ogg\meson.build: ogg_dep = dependency('ogg', version : '>=1.0', required : get_option('ogg')) ). Apart from ogg, there are many components unbuilt.

    Do you have any suggestion as to what could've gone wrong? If it's really because of a dependency, is there a list of "packages" that need to be installed? I'm guessing ogg would be already present in a base linux installation, but I'm doing the build on Windows.

    Reply to this comment

    Reply to this comment

    1. Aaron Boxer:
      Jan 07, 2020 at 03:17 PM

      Unfortunately I'm not sure what the problem is with ogg : you might want to post an issue to the gst-build Gitlab repo: https://gitlab.freedesktop.org/gstreamer/gst-build

      Reply to this comment

      Reply to this comment

  4. Bishwaroop:
    Mar 30, 2020 at 10:14 AM

    While running the ninja -C build it fails when linking the Open264 citing x86 and x64 mix up. this is supposed to be x64 build right.

    subprojects\openh264\codec\common\8b33b39@@common@sta\cpuid.o : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'


    When i see the folder they have only x86 linkage folders..

    Am i missing some step?..I am using 2019 visual studio natuve x64 command as mentioned above.

    Reply to this comment

    Reply to this comment

    1. Aaron:
      Mar 30, 2020 at 01:15 PM

      Hi Bishwaroop , it's hard to say what the problem is as every environment is different. Have you built GStreamer before on this system for x86 ?
      Try deleting the build directory and trying again. If error persists, you might want to open an issue on the gst-build Gitlab repo.

      Reply to this comment

      Reply to this comment

      1. Bishwaroop:
        Mar 30, 2020 at 02:38 PM

        What i meant was the Open264 which is subprojects the meson build file refers to the x86 folders for the linkage. Since this build has target type set to x64 hence this fails.
        quite possibly the reason. No i didnt build it for x86 as the default cloned git repo gives a meson for x64 build only.

        Reply to this comment

        Reply to this comment

        1. Aaron:
          Apr 03, 2020 at 08:59 PM

          Thanks for clarifying, in that case you should definitely open an issue.

          Reply to this comment

          Reply to this comment

  5. Gonzalo Carozo:
    Apr 03, 2020 at 07:24 PM

    Hi Aaron, thank you very much for the guide. I'm trying to develop gstremer in Visual Studio 2019 on Windosw 10,

    I followed the instructions, but after all, the GSTREAMER_1_0_ROOT_X86_64 stays empty, do you have a clue on what am I doing wrong?

    Reply to this comment

    Reply to this comment

    1. Aaron Boxer:
      Apr 03, 2020 at 07:29 PM

      Hi Gonzalo, glad you found the post helpful. It's hard to say what the issue is, do you mean the directory is empty, or the environment variable ?

      Reply to this comment

      Reply to this comment


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Search the newsroom

Latest Blog Posts

syzkaller: fuzzing the kernel

26/03/2020

With the code base of the Linux kernel constantly changing and deployed in devices around the world, performing proper testing is crucial.…

Getting started with GStreamer's gst-build

19/03/2020

GStreamer relies on multiple repositories such as base and good to build its ecosystem, and now owns more than 30 projects in Gitlab. So,…

Why remote working can be good for people, business and environment

10/03/2020

Here at Collabora, we trust our people to work remotely, we give them full responsibility for their output, and we believe it helps creating…

PipeWire, the media service transforming the Linux multimedia landscape

05/03/2020

PipeWire 0.3 was released a few days ago, marking a big step forward in the effort of making this emerging media service the core layer…

Experimental Panfrost GLES 3.0 support has landed in Mesa

27/02/2020

Panfrost's ES 3.0 support has landed in upstream Mesa and works with a mainline Linux kernel. The support is still early, but if you're…

Using gcc sanitisers to get a nasty bug fixed

18/02/2020

When a bug surprises you when doing Apertis packaging of a typical vendor code signing tool, it's time to debug it using the compiler's…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2020. All rights reserved. Website sitemap.