Category Archives: Ubuntu

Heroes of the Storm for Linux

A friend of mine asked if I wanted to play Heroes of the storm with him. But then I found out that the creators were blizzard, and they are known to hate Linux. But often you can emulate windows games, and heroes of the storm should be no difference right?

In this post I will show how to install Heroes of the storm though wine in a container.

Table of Content

  • Introduction
  • Step 0 Install lxc
  • Step 1 Install missing package
  • Step 2 Fix the gui
  • Step 3 Graphics
  • Step 4 Wine
  • Step 5 Heroes of the storm
  • Step 6 Further

Introduction

These days steam are making games more common for Linux ( well, ubuntu at least) but it’s always been the downside of Linux. The solution for this has in many cases been to use a windows emulator called Wine. My experience with OS emulators (like cygwin) are that they tend to make a mess of your installation. For the last few years containers has been hot stuff with Linux. It’s a semi VM, it actually runs on your hosts kernel (protected by namespaces) and it is really useful for just this kind of situation when you don’t want to install a horde of compatible libraries on your machine.

Is it possible to combine containers and wine? Well yes!

Step 0 Install lxc

Containers are easy to create, but they can really put your linux knowledge to test when you want to modify them and grant permissions. I recommend you to read Stéphane Graber posts at https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/ before you try what I do in this post. A lot of the graphics is taken from his post about gui.

Install lxc

# apt-get install lxc

Then let’s create a container called wine

lxc-create -t download -n wine

You will have to select distro, version and architecture.

  • Distro: I picked ubuntu and for two good reasons. 1: My host is ubuntu making it easier to compare with the guest (especially for fixing the gl drivers) 2: a lot of programs are made for ubuntu making installation less of a hazzle.
  • Version. I picked same as my host: wily. Much for the same reason as mentioned in 1 above.
  • Architecture: I found the i386 being slightly easier to install than amd64, but I prefer having 64-bit.

There are some difference in the error output you get when using 32 respectively 64-bit architecture. I’ll post both output, but keep in mind that it might differ depending on architecture.

Start it and log in to make sure everything went ok.

$ lxc-start -n wine

$ lxc-attach -n wine

update

# apt-get update;apt-get upgrade

tips: to log out you can send EOF with ctrl+D

Step 1 Install missing package

Log in to your guest. First of all, if you use any other locale than US you should install the correct language package to avoid the annoying error message:

perl: warning: Setting locale failed.

I’m using Swedish:

2016/05/heroes-of-the-storm-for-linux# apt-get language-pack-sv

Next you want to  add auto completion:

# apt-get install bash-completion

start it by: . /etc/bash_completion

If you use the terminal a lot it can be a good idea to put it in .bashrc

Step 2 Fix the gui

Next thing we should install some GUI application . Install chromium, it will be used later in the tutorial anyway (and in heroes of the storm when it want to show a web page from battle.net)

# apt-get install chromium-browser

(500 Mb!)

Try to start it.

Gtk: cannot open display: :0

Problem with open the display. That’s not so strange. The container is minimum installation of  ubuntu, no desktop environment and no xorg.

Let’s use the hosts xorg by mounting it to the guest. Add following section in .local/share/lxc/wine/config

#mounts
lxc.mount.entry = /tmp/.X11-unix tmp/.X11-unix none bind,optional,create=dir

I also had to allow connection by: xhost +

This is probably not good for security to allow anyone to connect. I haven’t tried but you can probably tweak it and use localhost for allowed IP addresses.

Stop the container and restart it.

Chromium will now complain that you are using root — as it should. Surfing from root is a really really bad idea.

lxc created a user “ubuntu” in my guest tat is user 1000. If you do not have one then create one with adduser and make sure it is uid 1000. Switch to the user.

# su – ubuntu

Now chromium should work!

Try to use the unprivileged user as much as possible. Obviously you need to be root to install packages, but don’t run wine and other programs as root.

If you get the error:

[0520/102117:ERROR:nss_util.cc(98)] Failed to create /home/ubuntu/.pki/nssdb directory.
[0520/102118:ERROR:nss_util.cc(98)] Failed to create /home/ubuntu/.pki/nssdb directory.
[0520/102118:FATAL:chrome_main_delegate.cc(411)] Check failed: process_type.empty(). Unable to get the user data directory for process type: zygote

 

Then you need to map the guest user with a host owner that got permission to write to hosts: .local/share/lxc/wine/rootfs/home/ubuntu

This is done in the end of next step.

Step 3 Graphics

This was by far the toughest part to fix. I use ATI/AMD while most guides online use Nvidia. Those did not work very well for me, and I expect if you got another manufacture you probably have to do it different, but I will try to write how to troubleshoot and find what libraries you need.

Install opengl utils

# apt-get install mesa-utils

start glxgears

$ glxgears

ibGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

That’s bad news. Let’s see what glxinfo says:

$ LIBGL_DEBUG=verbose glxinfo

name of display: :0
libGL: screen 0 does not appear to be DRI2 capable
libGL: OpenDriver: trying /usr/lib/fglrx/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/fglrx/dri/swrast_dri.so
libGL: dlopen /usr/lib/fglrx/dri/swrast_dri.so failed (/usr/lib/fglrx/dri/swrast_dri.so: cannot open shared object file: No such file or directory)
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
libGL: Can’t open configuration file /home/zabbat/.drirc: No such file or directory.
libGL: Can’t open configuration file /home/zabbat/.drirc: No such file or directory.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
display: :0  screen: 0
direct rendering: No (If you want to find out why, try setting LIBGL_DEBUG=verbose)

This basically means that it’s not possible to use hardware and  you will make your CPU render. Also as we scroll through the text we can see that the gl version is really low (mine was 1.4).

How does it look like on the host side?

$ LIBGL_DEBUG=verbose glxinfo

name of display: :0
display: :0  screen: 0
direct rendering: Yes

….

libGL: OpenDriver: trying /usr/lib/dri/fglrx_dri.so
ukiDynamicMajor: found major device number 243
ukiDynamicMajor: found major device number 243
ukiDynamicMajor: found major device number 243
ukiOpenDevice: node name is /dev/ati/card0

The driver it is using is fglrx. Let’s install this on the guest too.

# apt-get install fglrx

(Almost 500Mb!)

reboot and run glxinfo again.

name of display: :0
libGL: AtiGetClientDriverName: 15.20.3 fglrx (screen 0)
libGL: OpenDriver: trying /usr/lib/fglrx/dri/fglrx_dri.so
libGL error: OpenDriver: failed to open /usr/lib/fglrx/dri/fglrx_dri.so, error[/usr/lib/fglrx/dri/fglrx_dri.so: cannot open shared object file: No such file or directory]
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
libGL error: OpenDriver: failed to open /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so, error[/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so: cannot open shared object file: No such file or directory]
libGL: OpenDriver: trying /usr/lib/dri/fglrx_dri.so
ukiDynamicMajor: found major device number 243
ukiOpenDevice: node name is /dev/ati/card0
Error: No root privilege. Please check with the system-admin.

Better!

The gl version is higher but still low:

OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: AMD Radeon R9 200 Series
OpenGL version string: 2.1 (4.5.13399 Compatibility Profile Context 15.201.1151)

let’s try glxgears again:

open uki failed (Operation not permitted)
libGL error: reverting to (slow) indirect rendering

“ukiOpenDevice: node name is /dev/ati/card0
Error: No root privilege. Please check with the system-admin.”

and

“Operation not permitted”

tells us that accessing the driver is not going well.

To fix this we should mount the driver. Add

lxc.mount.entry = /dev/ati/card0 dev/ati/card0 none bind,optional,create=file

in  the config file. Containers still don’t like any user to have permission to mess with  device drivers, so we should add it as an exception. We are using /dev/ati/card0, let’s check the device version numbers for it. On the host:

$ ll /dev/ati

crw-rw-rw-  1 root root 243, 0 maj 15 19:48 card0

Add the permision for the device in the config file:

# groups
lxc.cgroup.devices.allow = c 243:* rwm

restart the container and try gears again. It should work.

glxinfo gives:

ukiOpenDevice: node name is /dev/ati/card0
ukiOpenDevice: open result is 4, (OK)
ukiGetBusid returned ‘PCI:1:0:0’

It could be useful to add mappings from you container to your host so that you user has same permissions. I’m not sure if you need this, but if you get any problem add:

lxc.id_map = u 0 100000 1000
lxc.id_map = g 0 100000 1000
lxc.id_map = u 1000 1000 1
lxc.id_map = g 1000 1000 1
lxc.id_map = u 1001 101001 64535
lxc.id_map = g 1001 101001 64535

in your config ( remove any other default mapping).

Step 4 Wine

The current supported wine version in ubuntu is 1.6 and that does not work very well with Heroes of the new earth. Install a newer version, I used  the latest (1.9.9) staging. Newer version usually got much better performance and when using 1.6 the game would freeze.

# apt-get install software-properties-common

For i386:

# add-apt-repository ppa:wine/wine-builds
# apt-get update
# apt-get install –install-recommends wine-staging
# apt-get install winehq-staging

https://github.com/wine-compholio/wine-staging/wiki/Installation#-ubuntulinux-mint

If you are on 64-bit then:

# add-apt-repository ppa:wine/wine-builds
# apt-get update
# apt-get install –install-recommends wine-staging-amd64

trying to install:
# apt-get install winehq-staging

will give you:
The following packages have unmet dependencies:
winehq-staging : Depends: wine-staging (= 1.9.10~ubuntu15.10.1) but it is not going to be installed

you must add multi arch:
# sudo dpkg –add-architecture i386 

Step 5 Heroes of the storm

Open chromium and download the installer:

https://us.battle.net/account/download/

once downloaded start it. Remember to not be root when you shouldn’t.

wine installer.exe

(or wine64)

I had problems that when there were an update I would get an error message :

“To install this game, please run the Blizzard Setup program while logged in to this computer as an administrator.​
Errors: BLZBNTBTS00000023, BLZBNTBTS00000024, BLZBNTBTS0000H”

I solved this problem by removing white space in the installation path:

c:\program_files\heroes_of_the_storm\

Note that blizzard will automatically install it to a folder with white space “Heroes of the storm”, but you can rename it afterwards and then go to settings and change the installation folder.

Step 6 Further

In this post I have not added sound.

https://www.stgraber.org/2014/02/09/lxc-1-0-gui-in-containers/ should give you the needed information.

The game works well in minimal graphics settings (35~40 fps in game), thought I’ve notice my ping can be high some times. I suspect the performance depends quite heavily on wine. It would be nice to see how much different the game would be if it was installed on my host, and on real Windows on my machine.

I am considering to add this as a docker. It could be a future project.

GL HF noob.

 

Brackets and the curse of dependencies

So the other day I wanted to install Brackets for front end development. No problems, it’s open source, how hard can it be?

Thought when trying to install from the deb file on my ubuntu 15 I get the error message that there’s no libgcypt11 that are a required dependency.

That’s not strange, it’s deprecated and new systems should use libgcrypt20, that comes with ubuntu 15. But unfortunately the install script still require libgcrypt11 ( >= 1.4.2)

Sure, it’s open source, why not download the source and change the dependency?

Turns out that creating the build script is not that easy. You need to run the grunt tasks, thought “grunt installer” won’t complete unless you do a full build. Guess what, full build won’t complete because the source code require symbols from libgcrypt11.

OK, what about to manually edit the install scripts in the deb file? Unpacking the deb file and changing the control file to libgcrypt11( >= 1.4.2) | libgcrypt20 (>= 1.5.0)

Nope, there’s still a library that don’t work without a call to a crypt function of version 1.2 :(

My advice? If you are going to use a virtual machine anyway, install an older distro, such as Ubuntu 14.

Reading the comments on Brackets they seem to have big problems to create a installer for new Linux distros. For over a year they have not managed to solve this issue. The conclusion is that they don’t really care about Linux so it’s a good idea to use another software. I’ll try Atom.

Another reason I like rolling releases is that you often avoid these dependency problems. Thank you Arch.

 

 

 

 

Virtualbox – Android Development Setup

In this guide I will show how to set up a Linux guest OS for Android development.

Requirements:
Basic Linux usage.
Basic Android Studio usage.
Virtualbox installed.

Toys/Equipment:
Android Device – If you want to learn how to run your app on a device and not emulator. I’m using a Sony z1.

Time:
Around 30 min.

Table of content

Introduction


Android is based on Linux and most tools for developing is made for Linux. I used to develop using Windows but it was never as smooth as for Linux. Sometimes my work has forced me to use a Windows machine and then the first thing I do is to install a linux VM. I really hate to use Cygwin – why try imitate Linux when you can have the real thing?
Now using virtualbox for Android isn’t totally pain free since you need to use adb through USB, something that can be tricky to set up correctly, especially if your host is Linux.

Step 0 – Xubuntu


When I first started to use Ubuntu I loved it. It was not full of things I didn’t need as in Windows and it was quite user friendly. However, after a while I started to feel it was bloated and I never liked Unity. Unity throws big icons in my face and more than a few times it is incompatible and you have to do a lot of research to solve the problems.
If you are going to use your VM for Android development I instead recommend Xubuntu. It is very similar to Ubuntu, but it is stripped down and the desktop environment xfce is much more in my taste.

In this guide I will be using Xubuntu, but it should be fine to use any Ubuntu clone.
Download and install Xubuntu here:
http://xubuntu.org/

In this guide I’m using Xubuntu 14.04 64-bit. First thing to do is to is to update the guest OS. Note that for this guide ‘$’ means normal shell command, while ‘#’ means executed as super user.
#apt-get update
#apt-get upgrade

Step 1 – Why is my screen so small?!


This is probably everyone’s first question when they have installed a Linux guest.
Pressing [right ctrl + f] enter full screen mode, but still the working area is 800×600. You need to install the guest additions to get a higher resolution. The good news is that for Ubuntu it is easy (while it is somewhat more demanding for other distros such as CentOS).

Install the guest addition for x11 and reboot:
#apt-get install virtualbox-guest-x11
#reboot

Ah, that’s better!

Step 2 – Android Studio


Android Studio requires Java, and of course if you are going to develop for android you need Java 7+. Xubuntu doesn’t come with java so you have to install:
#add-apt-repository ppa:webupd8team/java
#apt-get update
#apt-get install oracle-java8-installer

java_alternatives

Check the configuration with:
#update-alternatives–config java

Download Android Studio:
https://developer.android.com/sdk/index.html#Other

Make sure you choose “All Android Packages” and not “SDK tools only”. In this guide I have used android-studio-ide-141.1980579-linux.zip.
Extract the archive. I extracted it to ~/android/android-studio

If you have 64-bit version of your guest, then you will have to install some 32-but libraries to be able to run Android Studio.
#apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6

Start android studio:
$android/android-studio/bin/studio.sh

I found Darcula them doesn’t look good in Xubuntu so I choose the default IntelliJ.
You will have to download the SDK. At some of my positions we had our own SDK but I haven’t found a way to skip this step. I installed it to ~/android/sdk

Step 3 – Android Project


Create a new Android Project with a blank activity. Connect your Android Device with USB. Run the app [shift F10]
The Choose Device dialog is empty.

Check the status of the USB on the guest:
$lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Hmm… there’s no USB device connected. Try to run the same command on your host if you run Linux, or check “This PC” if you use windows. The USB is visible at the host right?

To allow the guest to detect USB you need to add it to the VM USB Device Filters.
Open virtualbox and click USB and then on the USB with a green plus sign. You should see your device in this list. Select it and make sure it is checked and then press OK.


Only one OS (host or guest) can control an USB device at the same time. This is important to remember when you troubleshot your USB. The Device Filter control if the guest OS should use the USB or the host.
Disconnect the USB and reconnect it and check for devices on your guest.
$lsusb
Bus 001 Device 004: ID 0fce:d107 Sony Ericsson Mobile Communications AB

That’s better!
Don’t forget to check the “USB debugging” in developers option of the Android Device.

Step 4 -Troubleshooting


“Unable to run mksdcard SDK tool” when installing the SDK:
You are missing 32-bit libraries:
#apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6

I use Linux and I can’t see my USB device:
You need to add yourself to vboxusers group, or you wont have permission to access the USB devices.
#adduser $USER vboxusers

https://help.ubuntu.com/community/VirtualBox/USB

I can find my device but not use it in Android studio:
Make sure USB debugging is on on the android device.

adb devices shows ?????? as id:
adb does not have the correct premissions. Try to restart it as super user:
$adb kill-server
#adb start-server

Conclusion


Setting up an Android development environment on a guest is quite same as on a host. The only thing you need to consider is the USB support. Your key tools when trouble shooting  is lsusb and adb.  adb devices gives you information about the android device, while lsusb gives you information about USB devices.
I prefer Xubuntu, but if you want a really easy installation I recommend Linux mint http://www.linuxmint.com/download.php. It automatically installs the guest drivers (and cinnamon looks damn good).  Cooperates should really consider using mint instead of Ubuntu.