Is there a workaround for a slow X11 server running from WSL? - user-interface

I recently cloned a GitHub repository into my Windows 10 PC. As the code was mostly in C++ it had to be compiled and built to be able to generate a working GUI.
To do so I used WSL, which allowed me to compile, build and run (using CMake), but as WSL doesn't have it's own display I had to use an X11 program (VcXsrv) for visualization. This last one seems to be making the interface rather slow, because the FPS indicator never goes above 15 and I'm told that the native build works at 60 FPS.
I'd like to know if there is a simple workaround that I can try from WSL to make it faster, as my other option is to try and learn Visual Studio.
The code run in WSL Ubuntu 20.04 is:
git clone --recurse-submodules https://github.com/nmwsharp/vector-heat-demo.git
cd vector-heat-demo
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
export DISPLAY=localhost:0
./bin/vector_heat /path/to/your/mesh.obj
And on the Windows side, I'm using VcXsrv settings: multiple windows, display 0, start no client, disable native opengl, from this answer.

The reason why it’s slow is the architecture of wsl1. See below.
Comparison WSL1 and WSL2
In WSL1 linux kernel is kind of emulated, there is a software layer which maps linux syscalls to windows syscalls (this means you loose some time when accessing devices) which will lead to low FPS in your case.
In WSL2 microsoft created a hypervisor on which win10 and the microsoft linux kernel is running (your ubuntu, debian, ... runs on top of that), which means WSL2 is way faster because of skipping that translation layer (more information can be found here: differences WSL1 & WSL2
I've also created a guide how to use it with X11 see here (which works for me)
VSCode connect to WSL
it’s just for coding not for running your gui
In this scenario a headless VSCode (Server) is started in your WSL. The VSCode on your Windows will than connect to this instance (meaning you'll have the linux filesystem + gcc toolchain available.
VSCode Remote WSL Documentation from microsoft

Related

How to run LibTool?

Currently I have tested my tool with clang-llvm installed on the machine I'm developing it on. All I have to do is go into build/bin to run my tool.
However, I now want to try running this tool on another machine.
What should I be doing here to run the tool I develop?
Do I have to setup the entire clang-llvm environment too? That's very time consuming and the entire folder is about 22+ GB in size..
The tool I'm creating is running RecursiveASTVisitor (same environment as the link below)
http://clang.llvm.org/docs/LibASTMatchersTutorial.html
Since you are just trying to run the tools on another machine, you can just transfer the whole llvm files and build files. IF you are running it on a different OS, you have to build the whole llvm and clang again as different OS (such as Windows) need extra tools such as cygwin .

Docker native Windows support?

I have a hard time finding information about this. Somewhere I've seen news that Docker has now natively been integrated to Windows. So apparently this means they are not "Linux container" but some kind of "Windows containers"? Does anyone have more information on this?
There has been a significant update thanks to many Docker acquisitions, such as Unikernel. Now it is possible to install beta (as of April '16) of Windows program running Docker without any hassle.
Faster and more reliable: no more VirtualBox! The Docker engine is running in an Alpine Linux distribution on top of an xhyve Virtual Machine on Mac OS X or on a Hyper-V VM on Windows, and that VM is managed by the Docker application.
UPDATE (September '17)
Full native support available here.
An integrated, easy-to-deploy development environment for building, debugging and testing Docker apps on a Windows PC. Docker for Windows is a native Windows app deeply integrated with Hyper-V virtualization, networking and file system, making it the fastest and most reliable Docker environment for Windows.
Microsoft has added containerization primitives to the Windows kernel and are helping porting Docker Engine to Windows. That means you can run native Windows containers with Docker on Windows Server 2016. It's been in tech preview for a while and is free to try. Details here: https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/manage_docker?f=255&MSPPError=-2147217396
I have read this:
https://azure.microsoft.com/blog/2015/04/16/docker-client-for-windows-is-now-available/
As you can read there is only interface to manage docker containers inside Linux so far.
Currently (October 2016) there're a mess here.
Windows Server 2016 and Windows 10 build 1607 (Anniversary Update) support Docker containers natively. Obviously only with Windows as base images. Moreover only with Windows Server 2016 (Nano or Core).
But there's also Docker for Windows - which is the only suggested option on https://www.docker.com/products/docker#/windows. It's easily can be thought that that Docker is the one which runs natively on Windows. But it isn't!
Docker for Windows uses a VM with Linux to host all containers. So you can't pull Windows images.
So a try to pull an image will fail with "unknown blog" error:
C:\>docker pull microsoft/nanoserver
Using default tag: latest
latest: Pulling from microsoft/nanoserver
5496abde368a: Retrying in 1 second
94b4ce7ac4c7: Downloading
unknown blob
So Docker for Windows can be used only for Linux images!
How f... it's obvious, right?
For "real native Docker" (to run Windows container) we currently have download and install it manually as described in this manual - https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/quick_start_windows_10

How to use Eclipse (IDE) with Cygwin (Linux emulator)?

I apologize in advance for the stupidity of this question, but I am confused as h#&! and not even sure what to ask anymore.
For my math thesis - i.e., I am not a programmer - I have to write C code which uses the CVODE library, which is part of SUNDIALS (do you need all that detail?). But I can't work directly on the Gentoo Linux cluster where the proram will ultimately run.
According to the SUNDIALS' website, CVODE has very rarely been compiled and used in a native Windows environment, but it has been used using Cygwin. So I want to set up a C programming environment, including an IDE (especially a debugger), on my Windows PC, using Cygwin.
I have installed and executed the basic Cygwin (plus a package for nano editor) on my 64-bit Windows PC. I want to use Eclipse IDE, which is available for Linux and Windows, and can really only be used in a graphical interface (I think). I think I should set Eclipse up next (and then CVODE after that). That's what I'm trying to do now.
My basic question is how do I setup Eclipse to work with Cygwin? What Cygwin packages do I need to run Eclipse?
From the docs, I see that Cygwin has a server (Cygserver), but does not have a graphical interface. Or, it might have a graphical interface called Cygwin/X. Do I setup Eclipse in Windows to communicate with Cygserver, then do my work in Windows, but compilations and so forth would take place in the Cygserver? Or, do I install Cygwin/X and use a Linux version of Eclipse which, hopefully, works with Cygwin/X? If both are possible options, which is easier (I'm guessing the latter).
Cygwin is nice but I've run into issues now and then with it. I would recommend that you download Virtualbox or some similar VM software and install the same Linux that is there on your production cluster inside it. Then you'll have an environment on your development machine which matches the production one.
Now, install eclipse (and anything else you want) inside the VM and you can develop the software there smoothly without worrying about tangential issues like cygwin and the rest.

Running Xcode 4 locally, executing code externally?

We have a CUDA server at work that is running Linux.
I am running Xcode on my Mac which does not have a CUDA device. I wondered if it was possible to use Xcode 4 as an IDE to develop the code, but executing/building and debugging the code on the external CUDA server?
In other words, I want to store the files etc, on the CUDA server (I have SSH access), but manage the project/files from my Mac. When I press the build button in Xcode, I want everything to be build on the CUDA server.
Is this possible or do I have to use ssh and vim to develop my code?
How about mounting the Linux server over SFTP through the Finder, and then using Xcode to start a project directly on the server? It might be tricky to tell Xcode where to find the nvcc compiler and other necessary stuff on the Linux server, but I would try that first.

Developing Linux software on Windows

I want to write software for the Linux platform, but I would like to do this on a Windows OS. I'm only developing Linux software for a remote server of mine, so it wouldn't be worth it to switch to Linux just for that. I don't think it's as simple as using a cross-compiler, because I will be writing code that uses headers specifically for Linux, and I would like to test the programs on Windows. I don't want to use VirtalBox etc.
If possible, install the entire development environment on the linux server. Then install an Xserver (e.g XMing) and an ssh client (e.g putty) on your Windows box. Then run the dev. environment remotely.
The big pro of doing this is that the linux windows integrate seamlessly in the Windows enviornment. I used to work with dual platform development and had a virtual linux box on my PC. Still, I used ssh+X-forwarding to access it. This way I got full copy-paste support etc. between the environments.
Now WSL (also known as "Bash on Windows") exists, you can run native Linux binaries directly on Windows. With snapcraft you can package Linux applications entirely under Windows, without using a VM. Might be a better option. I made a super quick video to explain it.
CoLinux allows you to run linux side-by-side with Windows.
You could try VirtualBox and virtualize a Linux environment from within Windows. I do the reverse of what you are trying to do and run Windows from Linux, and it works quite well.
If you are familiar with .NET and C# you can use Mono for your client.
You can use Visual Studio to develop and the Mono runtime one Linux to run the application.
You do need to keep away from windows specific code.
Maybe Cygwin could help. You don't need an entire virtual machine and only the api is emulated.
You could use g++ in cygwin to target a linux binary. It's a pain to setup as you noted you'll need the entire toolchain (not just the compiler). I've used crosstool (domain name makes me giggle every time) in the past with success. It looks like someone did the work already http://metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.html
However I've never targeted linux from windows. I'd install a virtual linux box, way easier and you're likely going to want to do your testing on a real linux box before going live.
Cygwin isn't linux so you can't test your linux binaries there.
Out of curiosity what's keeping you from doing the development on linux? If the server the app runs on isn't mission critical you could even develop there.

Resources