Skip to content
Zwetan Kjukov edited this page Dec 9, 2015 · 22 revisions

Linux Ubuntu Setup

Everything you have to install and setup to be able to compile Redtamarin under Ubuntu.

The Basic

We are installing a Linux Ubuntu Desktop 15.10 64-bit,
simply download an ISO from the Ubuntu web site.

Once the system is installed, update
$ sudo apt-get update
$ sudo apt-get upgrade

Also in "system settings / details"
check for available update
and update if necessary.

Usually you would remote control a Linux desktop using VNC,
but it is too slow, so we opted to use RDP instead (yes from Microsoft).

First, install a SSH server
$ sudo apt-get install openssh-server
now from either Windows, Mac OS X or another Linux
you can ssh from a Bash Shell
$ ssh [email protected].

ssh is convenient when you want to run something
without really using a GUI, like install a package, or run a build

Second, let's install a RDP server
$ sudo apt-get install xrdp

note: RDP listen on port 3389

unless you see:
Starting Remote Desktop Protocol Server [ OK ]
start the xrdp server
$ sudo /etc/init.d/xrdp start

RDP work only with a 2D desktop
and so will not work with the default Unity desktop (which is 3D).

install Mate
$ sudo apt-get install ubuntu-mate-core ubuntu-mate-desktop

Configure RDP to use a Mate session
$ echo mate-session > ~/.xsession
check the xrdp config to be sure we can reuse the session
$ sudo nano /etc/xrdp/xrdp.ini

it should be

[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1

if port=ask or port=ask-1, change it to port=-1.

now restart the server
$ sudo service xrdp restart

to verify
$ sudo /etc/init.d/xrdp status
you should obtain

 * Checking status of Remote Desktop Protocol Server xrdp    [ OK ]
 * Checking status of RDP Session Manager sesman             [ OK ]

When you will connect to this Linux from another machine using a RDP client, it may not work right from the first time, but try to reconnect a 2nd time and there it should work.

Depending on your Ubuntu version you may run into issues, check this c-nergy blog, Category: XRDP which contain lots of infos, setup etc. about xrdp config under Linux.

To remote control the machine

The "optional", install whatever you need as a developer like Windows Update, Google Chrome, Flash Debug version, Adobe AIR, your preferred code editor, etc.

The Development Stack

From that point, we install what we consider the "essential", and yes it will certainly be biased toward specific tools but it's what we're going with because we know it works, if you don't install those for whatever reasons we will not be able to help or support you.

Basic

Install Google Chrome
Linux 64 bit .deb (For Debian/Ubuntu)

Install Sublime Text 2
Linux 64 bit

In the Terminal
following How to Install Sublime Text 2 on Ubuntu 14.04

  • go to your download directory
    $ cd ~/Downloads
  • unzip it
    $ tar xf Sublime\ Text\ 2.0.2\ x64.tar.bz2
  • move the files into your "opt" folder
    $ sudo mv Sublime\ Text\ 2 /opt/
  • create a symlink so you can launch it from the Terminal
    $ sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/subl

Because we use Mate, adding a menu entry is done this way

  • go into "System / Preferences / Look and Feel / main Menu"
  • select "Applications"
  • select "programming" (on the right) and check it
  • select "programming" (on the left)
  • click "New Item"
  • input those infos
    • name: "Sublime"
    • command: "/opt/Sublime Text 2/sublime_text"
    • you can double click the icon and change it
      look into /opt/Sublime Text 2/Icon/48x48/

Command-line

Everything is in place you already have a Terminal and a Bash Shell.

To open the Terminal, click "Applications / System Tools / MATE Terminal".

You should get a prompt looking like this

username@machine:~$

Now let's install some tools
$ sudo apt-get install tree pkg-config unzip unrar
$ sudo apt-get install automake autoconf build-essential devscripts libtool patch
$ sudo apt-get install subversion ant mercurial git-core git-svn

Configuring your environment

  • Open a Terminal
  • go to your home directory
    $ cd ~ or $ CD $HOME
  • check if you have a .profile
    $ ls -la
    • if not, create a .profile
      $ touch .profile
  • edit it
    $ nano .profile

Right at the end of the file add

...
#umask 022

export TERM=xterm-color
export force_color_prompt=yes

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export EDITOR=nano
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=DxFxcxdxBxegedbxHxHcHd
export LS_COLORS="di=01;33;40:ln=01;95;40:so=32;40:pi=33;40:ex=01;91;40:bd=34;46:cd=34;43:su=31;40:sg=01;97;40:tw=01;97;42:ow=01;97;43:"

To apply the changes
$ source .profile

If you don't have tree installed
$ apt-get install tree

Now try to do a ls -la or a tree -L 1 /usr and you should have some nice colors in your terminal.

This is mainly about editing your .profile to add environment variables, if you want a custom color scheme use the LSCOLORS configurator, also look at Configuring LS_COLORS and Colorizing the Terminal.

If you can not or struggle to apply such configuration you should stop here, not trying to discourage you but what's coming next is much much more complex and so maybe you should get familiar with the Bash Shell and the Terminal first (you can find tons of tutorial online).

Configuring your environment for XRDP

  • Open a Terminal
  • edit the XRDP start script
    $ sudo nano /etc/xrdp/startwm.sh
  • before the line . /etc/X11/Xsession
    add
    . /etc/environment
    . /etc/profile

you should have something looking like

#!/bin/sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi

. /etc/environment

. /etc/profile

. /etc/X11/Xsession

About Terminal, Shell and dotfiles

If you use ssh to connect to a remote machine,
it will read your .profile because you "login".

But if you open the Terminal or MATE Terminal within an RDP session
your .profile will not be read because you are already logged in,
eg. you're using a non-login interactive shell.

We define all our config etc. in the .profile
so in this case we need to load the .profile
automatically (even if not recommended)

  • open a Terminal
  • then "Edit / Profiles..."
  • "Edit" your profile
    (eg. "Default" by default)
  • in the tab "Title and Command"
    check "Run command as a login shell"
  • with that each Terminal you will open
    will load the .profile by default

Java

We need Java to run Ant and compile with the Flex SDK.

Java SDK

Verify if you have Java
$ java -version

Wether it is already there or not,
install the default Java SDK
$ sudo apt-get install default-jdk

At best, it will install nothing, but usually it will install some missing files or fix a half-assed install.

Test Java
$ java -version

You should obtain something like

$ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-0ubuntu0.15.04.1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

Test JAVA_HOME
$ echo $JAVA_HOME
if the result is empty we need to configure our environment

But first we need to find where java is installed
$ which java
output: /usr/bin/java
$ ls -la /usr/bin/java
output: /usr/bin/java -> /etc/alternatives/java
$ ls -la /etc/alternatives/java
output: /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

  • Open a Terminal
  • go to your home directory
    $ cd ~ or $ CD $HOME
  • check if you have a .profile
    $ ls -la
    • if not, create a .profile
      $ touch .profile
  • edit it
    $ nano .profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/

export PATH="$JAVA_HOME/bin:$PATH"

Apply the changes
$ source .profile

your .profile should look like the following (without comments)

export TERM=xterm-color
export force_color_prompt=yes


# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export EDITOR=nano
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=DxFxcxdxBxegedbxHxHcHd
export LS_COLORS="di=01;33;40:ln=01;95;40:so=32;40:pi=33;40:ex=01;91;40:bd=34;46:cd=34;43:su=31;40:sg=01;97;40:tw=01;97;42:ow=01;97;43:"

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/

export PATH="$JAVA_HOME/bin:$PATH"
Ant

Install Ant
$ sudo apt-get install ant

Test if you can use Ant
$ ant -version

You will obtain

Apache Ant(TM) version 1.9.4 compiled on January 27 2015

All is working but for "same config everywhere" sake
$ nano ~/.profile

add the following

export ANT_HOME=/usr/share/ant/
Flex SDK

We want to install all SDK in the /sdk folder
and we want all Flex SDK to be in the /sdk/flex folder

  • open the Terminal
  • go to the root
    $ cd /
  • create the directories path
    $ sudo mkdir -p /sdk/flex
  • make the directory and subdirectories accessible by anyone
    $ sudo chmod -R 777 sdk/

Download the Adobe Flex SDK
For example: Adobe Flex 4.6 SDK

  • go into our flex sdk folders
    $ cd /sdk/flex
  • download the Adobe Flex 4.6 SDK
    $ wget http://download.macromedia.com/pub/flex/sdk/flex_sdk_4.6.zip
  • unzip it into the folder "4_6"
    $ unzip flex_sdk_4.6.zip -d 4_6
  • do not delete "flex_sdk_4.6.zip"
    we can reuse it in the future
  • go into the "4_6" folder
    $ cd 4_6/
  • test it
    $ bin/mxmlc

You should get

Loading configuration file /sdk/flex/4_6/frameworks/flex-config.xml
Adobe Flex Compiler (mxmlc)
Version 4.6.0 build 23201
Copyright (c) 2004-2011 Adobe Systems, Inc. All rights reserved.

Error: a target file must be specified

Use 'mxmlc -help' for information about using the command line.

Download the Apache Flex SDK
For example: Apache Flex SDK 4.14.1 (download from OVH)
List of mirrors: mirrors Apache Flex SDK 4.14.1

  • go into our flex sdk folders
    $ cd /sdk/flex
  • download the Apache Flex SDK 4.14.1
    $ wget http://apache.mirrors.ovh.net/ftp.apache.org/dist/flex/4.14.1/binaries/apache-flex-sdk-4.14.1-bin.tar.gz
  • untar it
    $ tar -xvjf apache-flex-sdk-4.14.1-bin.tar.gz
  • rename the folder to "4_14_1"
    $ mv apache-flex-sdk-4.14.1-bin 4_14_1
  • do not delete "apache-flex-sdk-4.14.1-bin.tar.gz"
    we can reuse it in the future
  • go into the "4_14_1" folder
    $ cd 4_14_1/
  • complete the installation with the Ant-based installer
    $ ant -f installer.xml -Dair.sdk.version=2.6 when asked questions answer "y" to all
  • install the playerglobal.swc
    $ mkdir -p frameworks/libs/player/11.1/
    $ wget http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc -O frameworks/libs/player/11.1/playerglobal.swc
  • now create some environment properties
    $ touch env.properties
    $ nano env.properties
    add
    env.PLAYERGLOBAL_HOME=/sdk/flex/4_14_1/frameworks/libs/player
  • make the binary files executable
    $ chmod +x bin/*
  • test it
    $ bin/mxmlc

You should get

Loading configuration file /sdk/flex/4_14_1/frameworks/flex-config.xml
Apache Flex Compiler (mxmlc)
Version 4.14.1 build 20150325
Copyright 2015 The Apache Software Foundation.

Error: a target file must be specified

Use 'mxmlc -help' for information about using the command line.

GCC

Find your GCC version
$ gcc --version

You should obtain something like

gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

List all the GCC installed
$ dpkg -l | grep "gcc" | awk '{print $2}' | grep "gcc"

You should obtain something like

gcc
gcc-5
gcc-5-base:amd64
libgcc-5-dev:amd64
libgcc1:amd64

As you can see we have gcc v5.

We want many things

  • use gcc 4.8
  • support 32-bit compilation
  • support 64-bit compilation

Install gcc v4.8
$ sudo apt-get install gcc-4.8

Install g++ v4.8
$ sudo apt-get install g++-4.8

Verify the versions installed
$ gcc --version

gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ --version

g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ls -la /usr/bin/gcc
output: /usr/bin/gcc -> gcc-5

$ ls -la /usr/bin/g++
output: /usr/bin/g++ -> g++-5

Configure GCC

First we erase the current update-alternatives setup for gcc and g++
$ sudo update-alternatives --remove-all gcc
$ sudo update-alternatives --remove-all g++

It's OK if you receive errors such as
update-alternatives: error: no alternatives for gcc
update-alternatives: error: no alternatives for g++

Install the alternatives

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20

$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20

$ sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$ sudo update-alternatives --set cc /usr/bin/gcc

$ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$ sudo update-alternatives --set c++ /usr/bin/g++

Configure the alternatives

$ sudo update-alternatives --config gcc
$ sudo update-alternatives --config g++

It will show you a menu of different versions of gcc installed on the system, select 4.8

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-5     20        auto mode
  1            /usr/bin/gcc-4.8   10        manual mode
  2            /usr/bin/gcc-5     20        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/gcc-4.8 to provide /usr/bin/gcc (gcc) in manual mode

now test the versions again

$ gcc --version

gcc (Ubuntu 4.8.5-1ubuntu1) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ --version

g++ (Ubuntu 4.8.5-1ubuntu1) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Install the gcc v4.8 multilib
(which allow to compile for both 32-bit and 64-bit)
$ sudo apt-get install gcc-4.8-multilib

Install the g++ v4.8 multilib
(which allow to compile for both 32-bit and 64-bit)
$ sudo apt-get install g++-4.8-multilib

Building Tools

Optional, but for case when we need a smaller exe
let's install a packer: UPX - the Ultimate Packer for eXecutables
$ apt-get install upx

for example: with the redshell_dd 64-bit
original size: 37M redshell_dd (38469216 bytes)
after $ strip redshell_dd
stripped size: 7.4M redshell_dd (7683152 bytes)
after $ upx -9 redshell_dd
packed size: 1.6M redshell_dd (1653184 bytes)

Use file to check the exe
for example in /bin-release/linux/64/debugger/
$ file redshell_dd
result:
redshell_dd: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped

for example in /bin-release/linux/32/debugger/
$ file redshell_dd
result:
redshell_dd: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, stripped

Use ldd to check for dynamic libraries
for example in /bin-release/linux/64/debugger/
$ ldd redshell_dd
result:

	linux-gate.so.1 =>  (0xf774c000)
	libpthread.so.0 => /lib32/libpthread.so.0 (0xf770e000)
	libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf7597000)
	libm.so.6 => /lib32/libm.so.6 (0xf754a000)
	libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf752c000)
	libc.so.6 => /lib32/libc.so.6 (0xf7374000)
	/lib/ld-linux.so.2 (0x565a2000)

note:
upx can change those results, as when you pack an exe
you create a stub which by nature is considered "statically linked"

without upx:
$ file redshell_dd
result:
redshell_dd2: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=52527e74b570a9b9036b0b7a85afec242689330f, stripped
$ ldd redshell_dd
result:

	linux-gate.so.1 =>  (0xf774c000)
	libpthread.so.0 => /lib32/libpthread.so.0 (0xf770e000)
	libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf7597000)
	libm.so.6 => /lib32/libm.so.6 (0xf754a000)
	libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf752c000)
	libc.so.6 => /lib32/libc.so.6 (0xf7374000)
	/lib/ld-linux.so.2 (0x565a2000)

with upx:
$ file redshell_dd
result:
redshell_dd: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped
$ ldd redshell_dd
result:

	not a dynamic executable

SDK

TODO

Redtamarin

We want to work from a folder named "work"

  • open the Terminal
  • go to the root
    $ cd /
  • create the directory "work"
    $ sudo mkdir work
  • make the directory and subdirectories accessible by anyone
    $ sudo chmod -R 777 work/

Follow the directions in Compiling Redtamarin.

Misc.

Create a bootable USB to install Ubuntu

Follow the instructions from How to create a bootable USB stick on OS X.

Under Mac OS X Yosemite I used

Create a bootable USB from the Terminal

  1. Convert the .iso file to .img using the convert option of hdiutil
    $ hdiutil convert -format UDRW -o ubuntu-15.10-desktop-amd64.img ubuntu-15.10-desktop-amd64.iso
    $ mv ubuntu-15.10-desktop-amd64.img.dmg ubuntu-15.10-desktop-amd64.img

  2. get the current list of devices
    $ diskutil list

  3. insert the USB key

  4. get the current list of devices
    $ diskutil list

    determine the device node assigned to your flash media (e.g. /dev/disk2)

    in my case:

      /dev/disk2
         #:                       TYPE NAME                    SIZE       IDENTIFIER
         0:     FDisk_partition_scheme                        *8.0 GB     disk2
         1:                 DOS_FAT_32 TEST                    8.0 GB     disk2s1
    
5. unmount the disk  
 `$ diskutil unmountDisk /dev/disk2`

 you should get  
 `Unmount of all volumes on disk2 was successful`

6. write the img to the disk  
 `$ sudo dd if=ubuntu-15.10-desktop-amd64.img of=/dev/rdisk2 bs=1m`

 wait ...

 you should get
 ```
   1123+1 records in
   1123+1 records out
   1178386432 bytes transferred in 88.655119 secs (13291804 bytes/sec)
 ```
 and also a popup window  
 "The disk you inserted was not readable by this computer"  
  [initialize...]                        [ignore] [eject]  
  you can click ignore or eject

7. Eject the USB key  
 `$ diskutil eject /dev/disk2`

Hardware

This is related to the Hardware Setup with the Gigabyte GB-BXBT-2807.

In the BIOS (firmware), see Ubuntu UEFI help

  • disable QuickBoot/FastBoot
  • disable Intel Smart Response Technology (SRT)
  • disable SecureBoot

During the setup at "Allocate drive space", chose "Erase disk and install Ubuntu".

Clone this wiki locally