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.

(Note on step 2: we will run meson from source, so 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 (you will need to have a Java JRE/JDK installed) (optional)

pkg-config

While not frequently used on Windows, pkg-config allows us to manage dependencies on other projects. After unzipping the binaries, put them 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 this file on your Windows PATH.

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\
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

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 ninja from the command line

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

And install with:

ninja -C build install

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 install as the build command.

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

      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 (18)

  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


Add a Comment






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


Search the newsroom

Latest Blog Posts

Using syzkaller, part 4: Driver fuzzing

26/06/2020

Syzkaller is much needed tool for Linux kernel testing and debugging. With some work, it can also be enhanced to find bugs in specific drivers,…

Cross building Rust GStreamer plugins for the Raspberry Pi

23/06/2020

Previously, we discussed about how Rust can be a great language for embedded programming. In this article, we'll explain an easy setup to…

Generating MPEG-DASH streams for Open Source adaptive streaming with GStreamer

12/06/2020

Adaptive streaming is a technique to provide flexibility and scalability by offering variable bit-rate streams to the client. Here's a quick…

Bifrost meets GNOME: Onward & upward to zero graphics blobs

05/06/2020

With only free software, a Mali G31 chip can now run Wayland compositors with zero-copy graphics, including GNOME 3. We can run every scene…

Using regmaps to make Linux drivers more generic

27/05/2020

Device drivers can support more revisions and SoC platforms by abstracting away specific hardware interface layouts. Let's examine a specific…

Cross-compiling with gst-build and GStreamer

15/05/2020

gst-build is one of the main build systems used by the community to develop the GStreamer platform. In my last blog post, I presented gst-build…

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. Privacy Notice. Sitemap.