windows-subsystem-for-linuxv4l2loopback

Install v4l2loopback in WSL2


I am currently struggling with v4l2loopback installation on WSL2.

Some context:

Recently, I have read about create a virtual video device in Linux and then mock its output from an image or video file.

This is quite important for testing or developing purposes, for example in order to attach a virtual webcam that reproduces a video file as a loop to the android emulator.

After some research I got to the conclusion I don't want to use desktop applications and it might be easy to run even in a CI or similar, therefore v4l2loopback looks nice, but I am currently a Windows user.

I enabled WSL2 on my machine, downloaded the repo, and tried to execute make command like in the repo description.

Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/angel/v4l2loopback modules
make[1]: *** /lib/modules/4.19.84-microsoft-standard/build: No such file or directory.  Stop.
make: *** [Makefile:43: v4l2loopback.ko] Error 2

I googled a little bit and i found that issue on GitHub where a similar output (for another tool) is mentioned. There, someone mentioned that WSL2 Kernel Config can be adjusted in order to add more modules ( maybe and hopefully one of them could make work v4l2-loopback 😂 or at least that I think).

I also googled in order to check out custom WSL builds but I am not really sure what I need to make it work or even if I am going in the right direction.

Is there something I 've missed in order to make v4l2loopback work?

In the case only a custom WSL2 build would work, how should I proceed?

Thanks in advance 🤘


Solution

  • I am not familiar with WSL...

    -- Ah, it appears WSL doesn't have a linux kernel at all: see https://unix.stackexchange.com/questions/594470/wsl-2-does-not-have-lib-modules . So it's useless building the v4l2loopback mod; even if you'd be able to build it, there's nothing, no kernel, to load it!

    Maybe an alternative for you might be running Virtualbox (it's free, and available for Windows) on your windows machine, and load a real Linux distro of your own choice in it. Then build the v4l2loop module, after installing the kernel development headers, and install the mod (after building, as root do insmod v4l2loop.ko) and play with it.

    Thus, you are on your way. Far more elegant, and far easier. Also will have you make an enormous and important climb on the 'getting familiar with Linux' ladder, as well as maybe familiarize yourself with a virtual machine(?).

    I'd definitely go for that.