We're hiring!
*

Building GStreamer on Windows

Aaron Boxer avatar

Aaron Boxer
November 26, 2019

Share this post:

Reading time:

Note: In September 2021, the GStreamer project merged all its git repositories into a single, unified repository, often called monorepo. The build system referred in this post as "gst-build" is now in the root of this combined/mono repository.

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:

Background

There are two official ways of building GStreamer on Windows - using cerbero or gst-build. As gst-build is a lot quicker, we will use this approach in this post.

Setup

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

(note on step 3: we will be running meson from source, so please skip the pip install of meson)

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

pkg-config

While not frequently used on Windows, pkg-config allows us to manage GStreamer dependencies on other projects. After unzipping the binaries, put their location on your Windows PATH.

Meson

After cloning meson, create a meson.cmd file with the following contents:

@echo off

c:\\PATH\TO\CLONED\MESON\SRC\meson.py %*

and put the file location on your Windows PATH.

Git

I 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.

Environment

Next, we set up a few environment variables (note the backslash at the end of the first three variables):

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\
PKG_CONFIG_PATH %GSTREAMER_1_0_ROOT_X86_64%lib\pkgconfig
GST_PLUGIN_PATH %GST_SRC_BUILD_PATH%gst-plugins-good;%GST_SRC_BUILD_PATH%gst-plugins-bad;%GST_SRC_BUILD_PATH%gst-plugins-base

Clone

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 from the Windows start menu:
     

    Visual Studio 2019 \ x64 Native Tools Command Prompt

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

Option 1: Build with ninja from command line

  1. Run ninja to build and install gst-build
    > ninja -C build install
    

Option 2: Build GStreamer with Eclipse

  1. Launch Eclipse from the x64 command 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 \ Builder Settings, un-check Use default build command and enter ninja -C build install as the build command.

  4. Right click on the gst-build project, select Properties \ C++ Build \ Behaviour and delete all from the Build (incremental build) box.

  5. Press Ctrl + B to build and install GStreamer.

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 Visual Studio breakpoints in GStreamer, open a 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

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.

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

  2. Open WSL and:
      $ sudo apt install git autoconf autopoint libtool make texi2html wget
      $ mkdir src && cd src
      $ wget https://ftp.gnu.org/gnu/indent/indent-2.2.11.tar.gz
      $ tar xvzf indent-2.2.11.tar.gz
      $ cd indent-2.2.11 && ./configure
      $ 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:

  > cd %SOURCE_DIR%gst-build\subprojects\SOME_GST_SUBPROJECT\.git\hooks
  > 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 (24)

  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

  6. Bill G:
    Apr 04, 2020 at 05:57 PM

    Great post and very helpful. I have built successfully with VS 2019 Community edition, installed on Windows 10 and verified with gst-launch-1.0 videotestsrc ! d3dvideosink. Good stuff!

    Now the problem - webrtcbin which is part of gst-plugins-bad is not being built because libnice is not building because openssl is not found. The Meson message is "Subproject directory not found and openssl.wrap file not found."

    I understand the wrap will bring in pre-built binaries potentially...but where do I get it and what is recommended way to install?

    Reply to this comment

    Reply to this comment

    1. Aaron:
      Apr 06, 2020 at 01:34 PM

      Hi Bill, I'm not sure what the magic incantation is to get webrtcbin building on windows - best to ask on the mailing list: https://gstreamer.freedesktop.org/lists/

      Reply to this comment

      Reply to this comment

    2. Ashok:
      Apr 12, 2020 at 03:34 PM

      I'm new to gstreamer. I have built successfully with VS 2017 Community edition, installed on Windows 10. I'm facing the same problem.
      webrtcbin which is part of gst-plugins-bad is not being built because libnice is not building because openssl is not found.

      Can you please help me how to resolve the issue.

      Thank you.

      Reply to this comment

      Reply to this comment

      1. Aaron Boxer:
        Apr 13, 2020 at 01:15 PM

        Hi Ashok, thanks for your comment. To solve this issue, I would recommend posting on the
        mailing list: https://gstreamer.freedesktop.org/lists/ or opening an issue on the gst-build gitlab
        site: https://gitlab.freedesktop.org/gstreamer/gst-build

        Reply to this comment

        Reply to this comment

  7. Kishore D:
    Sep 24, 2020 at 10:55 PM

    I am trying to built with VS 2019 Edition. Soon after I use the command "meson --prefix=%GSTREAMER_1_0_ROOT_X86_64% build"., I run in to this issue:

    None of 'CC' are defined in the environment, not changing global flags.
    None of 'CFLAGS' are defined in the environment, not changing global flags.
    None of 'LDFLAGS' are defined in the environment, not changing global flags.
    None of 'CPPFLAGS' are defined in the environment, not changing global flags.
    None of 'CC_LD' are defined in the environment, not changing global flags.
    Sanity testing C compiler: cl
    Is cross compiler: False.
    None of 'CC_LD' are defined in the environment, not changing global flags.
    Sanity check compiler command line: cl C:\Users\usr1\Workspace\gstreamer\gst-build\build\meson-private\sanitycheckc.c /FeC:\Users\usr1\Workspace\gstreamer\gst-build\build\meson-private\sanitycheckc.exe /MDd /nologo /showIncludes /link
    Sanity check compile stdout:
    sanitycheckc.c
    LINK : fatal error LNK1104: cannot open file 'ucrtd.lib'

    -----
    Sanity check compile stderr:

    -----

    meson.build:1:0: ERROR: Compiler cl can not compile programs.

    Reply to this comment

    Reply to this comment

    1. Aaron Boxer:
      Sep 28, 2020 at 09:10 PM

      Thanks for your comment, Kishore, It looks like you have a problem with your MSVC environment.
      I would recommend posting your meson log files (found in the build directory) to the meson
      issue tracker: https://github.com/mesonbuild/meson/issues

      Reply to this comment

      Reply to this comment

  8. Elliott S:
    Oct 24, 2020 at 11:46 PM

    You say:

    > 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

    but configured to what? true, false, or input?

    Reply to this comment

    Reply to this comment

  9. Aaron Boxer:
    Oct 26, 2020 at 12:19 PM

    thanks, Elliott. Is should be set to false.

    Reply to this comment

    Reply to this comment

  10. Our Endangered World:
    Sep 03, 2021 at 05:21 PM

    Hello, Aaron! Thank you for this extremely helpful post, especially for people who are new to the GStreamer!

    Reply to this comment

    Reply to this comment

  11. Gal:
    Oct 02, 2021 at 03:44 AM

    Hello, I followed the steps with gstreamer 1.18.5 and I am getting compile error:

    FAILED: subprojects/gst-plugins-bad/ext/spandsp/gstspandsp.dll.p/gstspanplc.c.obj
    "cl" "-Isubprojects\gst-plugins-bad\ext\spandsp\gstspandsp.dll.p" "-Isubprojects\gst-plugins-bad\ext\spandsp" "-I..\subprojects\gst-plugins-bad\ext\spandsp" "-Isubprojects\gst-plugins-bad" "-I..\subprojects\gst-plugins-bad" "-Isubprojects\gst-plugins-base\gst-libs" "-I..\subprojects\gst-plugins-base\gst-libs" "-Isubprojects\gstreamer\libs" "-I..\subprojects\gstreamer\libs" "-Isubprojects\gstreamer" "-I..\subprojects\gstreamer" "-Isubprojects\orc" "-I..\subprojects\orc" "-Isubprojects\gst-plugins-base\gst-libs\gst\video" "-Isubprojects\gstreamer\gst" "-IC:/gstreamer/1.0/msvc_x86_64/include/glib-2.0" "-IC:/gstreamer/1.0/msvc_x86_64/lib/glib-2.0/include" "-IC:/gstreamer/1.0/msvc_x86_64/include" "/MD" "/nologo" "/showIncludes" "/W2" "/O2" "/Zi" "/wd4018" "/wd4146" "/wd4244" "/wd4305" "/utf-8" "-DG_DISABLE_CAST_CHECKS" "/w14062" "/w14101" "/w14189" "/utf-8" "-DHAVE_CONFIG_H" "/Fdsubprojects\gst-plugins-bad\ext\spandsp\gstspandsp.dll.p\gstspanplc.c.pdb" /Fosubprojects/gst-plugins-bad/ext/spandsp/gstspandsp.dll.p/gstspanplc.c.obj "/c" ../subprojects/gst-plugins-bad/ext/spandsp/gstspanplc.c
    C:\gstreamer\1.0\msvc_x86_64\include\spandsp/fast_convert.h(320): error C2169: 'lrint': intrinsic function, cannot be defined
    C:\gstreamer\1.0\msvc_x86_64\include\spandsp/fast_convert.h(325): error C2169: 'lrintf': intrinsic function, cannot be defined
    C:\gstreamer\1.0\msvc_x86_64\include\spandsp/noise.h(1): warning C4828: The file contains a character starting at offset 0xb82 that is illegal in the current source character set (codepage 65001).
    C:\gstreamer\1.0\msvc_x86_64\include\spandsp/noise.h(1): warning C4828: The file contains a character starting at offset 0xb83 that is illegal in the current source character set (codepage 65001).

    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

Automatic regression handling and reporting for the Linux Kernel

14/03/2024

In continuation with our series about Kernel Integration we'll go into more detail about how regression detection, processing, and tracking…

Almost a fully open-source boot chain for Rockchip's RK3588!

21/02/2024

Now included in our Debian images & available via our GitLab, you can build a complete, working BL31 (Boot Loader stage 3.1), and replace…

What's the latest with WirePlumber?

19/02/2024

Back in 2022, after a series of issues were found in its design, I made the call to rework some of WirePlumber's fundamentals in order to…

DRM-CI: A GitLab-CI pipeline for Linux kernel testing

08/02/2024

Continuing our Kernel Integration series, we're excited to introduce DRM-CI, a groundbreaking solution that enables developers to test their…

Persian Rug, Part 4 - The limitations of proxies

23/01/2024

This is the fourth and final part in a series on persian-rug, a Rust crate for interconnected objects. We've touched on the two big limitations:…

How to share code between Vulkan and Gallium

16/01/2024

One of the key high-level challenges of building Mesa drivers these days is figuring out how to best share code between a Vulkan driver…

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-2024. All rights reserved. Privacy Notice. Sitemap.