Install v4l2loopback in WSL2 - windows-subsystem-for-linux

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 🤘

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.

Related

How to create and share a VM environment for development

I am working on a college project along with a group of people. Our goal is to add features to an already existing application that runs on the web. Currently, I'm in the process of getting the source code to run on my machine. This consists of cloning a bunch of repos, installing MySQL and some (very old and outdated :-| ) versions of Python, and running some scripts. The process sounds straightforward but it isn't; there are a lot of dependancies that need to be met for the code to run, which means that I need to spend a lot of time looking at error logs trying to figure out what package is missing and needs to be installed or downgraded. But that's not the point of this question.
I'd like to make it easier for people to pick up the project in the future and work on it without having to spend hours just to get the code to compile. I'd like to get the project set up on a Linux VM (something I know how to do using VirtualBox) and then somehow share (?) that VM so that other people can simply set it up and be able to immediately have the code compiling (something that I don't know how to do, or if it is even possible).
Additionally, I'd like to be able to do all the coding on the host OS if possible, and only do the compiling/running on the VM (something I also don't know how to do). I would like some help/pointers with all the "I don't know" 's, as I don't know much about VM's other than how to set one up using VirtualBox.
You can use Vagrant to automate the provisioning of the VM, and setup all your tools and dependencies using Docker.
There are many good tutorials and sample vagrantfiles online to get you started. There is a learning curve involved, but well worth the effort. Many companies use Vagrant to quickly provision dev environments.
Vagrant can automatically download a specific distro/version of a VM from the web if one is not already locally installed. It can also provision a Docker container, in which you can install any required dependencies, tools, etc. You can store the vagrantfile, dockerfile, scripts, etc. in GitHub for easy access by your colleagues. All they would have to do is install Vagrant and run vagrant up from the command line.
If you want to write code on the host machine and compile/test it on the VM, you will need to setup a shared folder in the VM using Guest Additions (see here). Be VERY careful with line endings if you are working in Windows and running in Linux. You can setup the shared folder with Vagrant as well (see here).

Can't find previously downloaded files in WSL

I'm not very experienced in *nix operating systems and I'm trying to set up an embedded programming environment in WSL, but I'm getting hung up on basic issues. Last time I was working on this project I had downloaded some files (cargo and rustup, but that shouldn't matter), and I confirmed that they were there and working by getting the version number with -V.
After restarting my computer WSL doesn't recognize rustup or cargo as commands, and the folders don't show up with ls, even though they show up when I check for them in Windows Explorer.
The directory I've been working out of is %LOCALAPPDATA%\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\home*user* which I'm pretty sure is the default. I’ve verified this by creating a .txt in WSL and finding it with Windows Explorer
Working on Windows 10 64-bit. I chose Debian for arbitrary reasons/ open to switching.
I’m not too worried about the files themselves, I just want to be able to avoid this in the future.
Firstly since you are new to WSL please be aware that the recommendations are to not under any situations edit or modify any Linux files inside of your %LOCALAPPDATA% folder using Windows apps or tools which includes moving files using file explorer. See this blog post from Microsoft https://devblogs.microsoft.com/commandline/do-not-change-linux-files-using-windows-apps-and-tools/ If you do you can see corruptions missing files and crashes.
I have no experience with cargo or rust but it sounds like you didnt update your .bashrc (start up script) with details needed to add things to the environment on start up.
There are a few things you can do
Use the history command to look back at what you did when you installed things
Use sudo find / -name rust to look for the executable in your system
When using ls remember that files/folders that begin with a dot are hidden so you need to use ls -al to see them in the terminal
I assume you followed this guide for installation (or similar). If you did not and are still having issues please detail how you installed things.

MXE compile on linux for linux

So I saw this project http://mxe.cc/ and tried it, it seems like it is very easy to compile stuff for windows with this. I tried to hack it a little bit to compile binaries for linux instead, because, if it compiles for other system so easily how can it be hard to compile for host? 90% of the stuff seems to just build out of the box, but there are some errors and therefore I cannot build. I want to ask, how correctly should I configure mxe to build for the linux host? I know this is not supported but I don't think it should be that hard because we build from source anyway. And there are next to no modifications for downloaded sources too (in a windows build that is).
For people who might ask why I don't want to use shared stuff, I want to basically have two options:
dpkg package for user with dependencies specified (the linux way)
single standalone static executable
Any suggestions? Or maybe there's whole another guide on linux on how to build things from scratch (without a lot of manual work like mxe does)?

Cygwin & OCaml: OPAM + Batteries

I extensively use Cygwin on a Windows 8 environment (I do not want to go ahead and boot/load Linux directly on the machine). I use the OCamlIDE plug-in for Eclipse and have experienced relatively no problems using this workflow setup.
However, I would like to use Batteries so that I may make use of use of its dynamic arrays among a few other interesting features that will speed up my development process.
I have tried this method: http://ocaml.org/install.html, but I get the following error:
$ sh ./opam_installer.sh /usr/local/bin
No file yet for i686:CYGWIN_NT-6.2-WOW64
What am I missing and how would I configure Cygwin so that it can accept the Opam installer? When I tried yet a different way of building Opam, I got:
'i686-w64-mingw32-gcc' is not recognized as an internal or external command,
as a Makefile error and reason for building failure. It seems something is wrong related to mingw32-gcc, what do I need to install and/or configure for my Cygwin to get it to compile/build things properly. I have wget and curl installed as well.
My overall question: What is the best way to get Batteries installed on my system with the minimum of time spent tracing all of its dependencies by hand? Is there a way I can just build the library module, such as BatDynArray and the includes:
include BatEnum.Enumerable
include BatInterfaces.Mappable
That way I can just call them directly in my code with open...;; and/or include...;;;
OCaml works beautifully on Windows with WODI, which is a Cygwin-based distribution that includes Batteries and tons of other useful packages (which are a pain to install manually on Windows).
I urge you to take a shot at WODI, which I believe to be an indispensable tool for the
rest of us, the forgotten souls, who have to deal with Windows.
First of all, include does not do what you think it does. open Batteries should be exactly what you're looking for. OPAM is not yet solid on windows (maybe Thomas could give an update on where things stand).
Frankly, I would recommend to install a linux on a VM, you should be able to get started with OPAM instantly then. Otherwise, take a look at this package manager for OCaml which focuses on cross platform support: http://yypkg.forge.ocamlcore.org/. I've never tried it myself however. The last package manger you could try is GODI, I'm not sure about its windows support though.
Finally, if none of these options work then it should be possible to install batteries from the source. All you need is OCaml and make. And if there are problems with this approach then you should definitely follow up on them either here or on the bug tracker because batteries does intend to support windows AFAIK.

Install Mono Runtime Locally

Here is my situation. I am on a Mac using Brew as my package manager. I had mono installed on my machine and I was doing all sorts of development in C#. I was doing web development, gui development, ect. When I tried to update my machine using Brew, I got an error. Uninstalling Mono solved the issue.
So, what I did is I toyed around and I created a 2nd user on my machine. Now, this user doesn't need anything to work. I just need Mono and Mono Develop to work on this user without installing anything globally. Everything needs to be installed locally.
So to be specific, I am the only on who uses my machine. My /Users directory looks like this.
/Users/dillon
/Users/dummy
So if I could install mono, in let's say:
/Users/dummy/.mono
Then in my .profile:
export MONO_PATH=/Users/dummy/.mono
Obviously this isn't a perfect world but I was wondering if anyone is an expert on this subject?
(Also, I use this dummy user for other stuff, I use it for Wine and I have a collection of software from school on this user.)
You need to build Mono from source to install it into a custom location (in which case you can install it anywhere you like).
You can install MonoDevelop.app anywhere, but getting it to use your custom Mono is a bit trickier. You might be able to make it work by mucking around with the relevant environment variables though.
How to install Mono in a custom location and the relevant environment variables is all covered here: http://mono-project.com/Parallel_Mono_Environments