Skip to content
Zwetan Kjukov edited this page May 29, 2016 · 27 revisions

Windows Setup

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

The Basic

We are installing a Windows 8.1 Pro 64-bit, you can see a comparison chart but here mainly why we want this version and no other.

  • Install and run desktop apps (x86/x64)
    the command-line tools produced by Redtamarin would not run under Windows RT
  • Maximum RAM 128GB
    be able to install at least 8GB of RAM
  • Remote Desktop (host)
    you can not control a non-pro Windows 8.1
  • 64-bit
    to build both 32-bit and 64-bit executables

When you install Windows 8.1, be sure to choose a username without spaces.

To remote control the machine

To install a SSH server see the part "SSH Server", but only after you configured "The Development Stack".

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

We need as much as possible tools or programs that can run cross-platform

  • Windows 8.1
  • Mac OS X 10.10
  • Linux Ubuntu 15.04

Install Google Chrome
Windows 10/8/7 64-bit

Install Sublime Text 2
Windows 64 bit

Command-line

Redtamarin is meant to run on the command-line and so we need to find a common ground of what kind of command line interface (CLI) we want to support.

Under Mac OS X and Linux we have POSIX, the Portable Operating System Interface standards which define

the application programming interface (API),
along with command line shells and utility interfaces,
for software compatibility with variants of Unix and other operating systems

One of the core API of Redtamarin implements most of those POSIX API, see the clib.

Following this logic we need and want to support the same POSIX features but at the shell level, and Windows "defaults" need to be replaced.

This is why we will use Cygwin by default under Windows, not only for development but also for the final user (which is basically a developer who want to use ActionScript 3.0 on the command-line).

For a Windows command prompt, I will use
C:\> some command
you don't type C:\>, you only type some command and then ENTER.

For a Bash shell, I will use
$ some command
you don't type $, you only type some command and then ENTER.

Download Cygwin
this: setup-x86_64.exe (save, do not run)

Now open a command prompt (WINKEY + X + C)
navigate to the download folder
C:\> cd %HOMEPATH%/Downloads
copy/paste the following batch script
(I name it redsetup.bat but you can name it whatever)

@ECHO OFF
REM -- Automates cygwin installation
REM -- for Redtamarin Windows Setup

SETLOCAL

REM -- Change to the directory of the executing batch file
CD %~dp0

REM -- Configure our paths
REM -- by default we use a US mirror in California
REM -- other mirrors can be found https://cygwin.com/mirrors.html
SET SITE=http://mirrors.kernel.org/sourceware/cygwin/
SET LOCALDIR=%LOCALAPPDATA%/cygwin
SET ROOTDIR=C:/cygwin

REM -- These are the packages we will install (in addition to the default packages)
SET PACKAGES=bash,bash-completion,mintty,which,diffutils,patchutils,nano
SET PACKAGES=%PACKAGES%,wget,hostname,openssh
SET PACKAGES=%PACKAGES%,subversion,subversion-tools
SET PACKAGES=%PACKAGES%,git,git-completion,git-svn
SET PACKAGES=%PACKAGES%,mercurial

REM -- Do it!
ECHO *** INSTALLING PACKAGES
setup-x86_64.exe -q -D -L -d -g -o -s %SITE% -l "%LOCALDIR%" -R "%ROOTDIR%" -C Base -P %PACKAGES%

PAUSE
REM -- Show what we did
ECHO.
ECHO.
ECHO cygwin installation updated
ECHO  - %PACKAGES%
ECHO.

REM -- Apt-cyg, an apt-get like tool for Cygwin
REM -- https://github.com/transcode-open/apt-cyg
ECHO installing apt-cyg
set PATH=%ROOTDIR%/bin;%PATH%
%ROOTDIR%/bin/bash.exe -c 'wget -P /bin https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg'
%ROOTDIR%/bin/bash.exe -c 'chmod +x /bin/apt-cyg'
ECHO apt-cyg installed

ENDLOCAL
 
PAUSE
EXIT /B 0

You will see the Cygwin popup window
just wait for the download to complete.

After that, type ENTER in the command-prompt
it will install apt-cyg, an apt-get like tool for Cygwin.

Now let's test all that
still in the command prompt
go to the root directory
C:\> cd /
then go into the cygwin directory
C:\> cd cygwin
run Cygwin.bat
and you should obtain a bash prompt

username@machine ~
$ 

Type few commands, like whoami, ls -la, hostname -I, etc.
and oh wait, if you type clear
the screen does not clear and you get the error
bash: clear: command not found

Search for clear.exe
$ cygcheck -p 'clear.exe'
now that you see it's inside the ncurses package
just install this package by typing
$ apt-cyg install ncurses
wait few seconds for it to install
type clear again, yep it works :)

Note:

  • you can run the redsetup.bat cygwin install script as many times you want
    • if you never ran it, it will download/install everything
    • if you already ran it, it will download/install nothing
    • if you delete some binaries, it will download/install only the one missing
    • if you ran it long long time ago, it will update the binaries to the latest versions
  • you can even run redsetup.bat if you already installed Cygwin
  • from now on we will ONLY use a Bash shell and NEVER use the Windows command prompt ever again
  • we will need to install more things along the way and we will mostly use $ apt-cyg install something except for special cases

Terminal

Windows use by default the "Command Prompt" as terminal (or console)
and cmd.exe (Wikipedia entry about cmd.exe) as its shell (command line interpreter), and thanks but no thanks.

We have already decided that we will ALWAYS use the Bash Shell, but for convenience and usability we want also to replace the Windows Command Prompt with a proper Terminal emulator, and for that we have many options.

cmd.exe

Open a Windows Command Prompt (eg cmd.exe)
go to the cygwin directory
C:\> cd /
C:\> cd cygwin
run Cygwin.bat

From that point we are in Bash Shell but many things are missing

  • no support for UTF-8
  • no support for ANSI (escape codes, colors, etc.)
  • no support for scrolling, copy/paste, etc.
  • this is the worst command-line experience you can get

We do not support cmd.exe, here a list of alternatives, see this article
What are the best terminal emulators for Windows?

Mintty

This is the default terminal installed with Cygwin and what we consider our strict minimum.

You will find it in the Windows Apps screen under the category "Cygwin" and named as "Cygwin64 Terminal", you can run it from there or right-click it and "pin it" to the taskbar.

You will differentiate it from the default command prompt by its "Cygwin icon" on the top left.

Once launched, right-click on the menu bar and select "Options...", in the "Terminal" properties change the "Type" to "xterm-256color", this is to be able to display ANSI colors, all other options are for you to decide.

By default, Mintty will directly starts the Bash Shell in your home directory (eg. /home/username) you will be able to copy/paste and other nice scrolling options etc.

See the Mintty wiki for Tips on setting up mintty and related programs.

ConEmu

Download it from its Github releases page, for example download ConEmuSetup.151126.exe and install.

During the setup we advise to use this startup task {Bash::CygWin bash x64 (1)}, for color scheme if you don't know use "Ubuntu" (it can be changed later).

Have a look at the screencasts to see a lot of powerful options.

For example, it will support tabs, nice colors and scrolling with the middle mouse button.

Cmder

Based on ConEmu and clink, you can download it from the main page, select "Download mini" (as we do not want to mix the git installed by Cygwin and the git for windows).

Unzip the file and place it in your C:\Program File>, to have shortcut right-click on the cmder.exe or also you can "pin it" to the taskbar.

It's like ConEmu but with the menu set on the bottom, and some customisation on the icon, the color scheme, the font etc.

The default install does not show all the "startup task", so right click the menubar and select "Settings...", then navigate to "Startup" then "Tasks" and click "Add default tasks..." answer "Yes" and from 3 default tasks you will get 11 and among them the one we want {Bash::CygWin bash x64 (1)}.

Now go back to "Startup" and in "Specified named task" select {Bash::CygWin bash x64 (1)}.

What do we ask from a Terminal?
  • support POSIX
    • the Bash Shell
      and the logic to configure it with
      .profile, .bash_profile, .bash_rc, etc.
    • the Filesystem Hierarchy Standard (FHS)
      so we have standards to where/how/etc.
      to install command-line tools, scripts, etc.
  • support an easy way to install/remove/etc.
    other command-line tools
    • under Windows with Cygwin we can use $ apt-cyg install something
    • under Mac OS X we can use $ port install something
    • under Linux Ubuntu we can use $ apt-get install something
  • support a "common" way to package tools for distribution
    • under Windows with Cygwin we can use wpkg
    • under Mac OS X we can use pkgbuild
    • under Linux Ubuntu we can use dpkg
  • support UTF-8
  • support ANSI colors
  • support copy/paste, scrolling, etc.

For all those reasons either use Mintty, ConEmu or Cmder with a Bash Shell.

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

...
# This file is not read by bash(1) if ~/.bash_profile or ~/.bash_login
# exists.
#
# if running bash
if [ -n "${BASH_VERSION}" ]; then
  if [ -f "${HOME}/.bashrc" ]; then
    source "${HOME}/.bashrc"
  fi
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:"

alias ls="ls --color=auto"
alias tree="tree -C"

To apply the changes
$ source .profile

If you don't have tree installed
$ apt-cyg 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).

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 (using Mintty, ConEmy, Cmder)
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.

Well ... it depends of how you launch that terminal window.

If you look at the "Cygwin64 Terminal" shortcut
thet terminal is launched with the following
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -

  • mintty looks for a shell to execute in the SHELL environment variable
  • -i /Cygwin-Terminal.ico
    load the window icon from an icon file
  • -
    If a single dash is specified instead of a program name,
    the shell is invoked as a login shell.

We define all our config etc. in the .profile
so in this case we need to load the .profile
automatically and the default above should work.

But it doesn't, here why
$ man bash

When bash is invoked as an interactive login shell,
or as a non-interactive shell with the --login option, it first
reads and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash_profile, ~/.bash_login,
and ~/.profile, in that order, and reads and executes commands from the
first one that exists and is readable.

By default Cygwin install those files in your HOME folder

.
├── .bash_history
├── .bash_profile
├── .bashrc
├── .inputrc
├── .minttyrc
└── .profile

Because of .bash_profile the file .profile is not read,
so let's correct that as we want to always load .profile
$ mv .bash_profile _bash_profile

Java

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

Java SDK

Download a recent Java SDK (minimum Java 1.6)
http://java.sun.com/javase/downloads/index.jsp
http://www.oracle.com/technetwork/java/javase/downloads/index.html

For example download Java SE 8u65 / 8u66 SDK
be sure to download the Windows x64 version
Java SE Development Kit 8u66
once you clicked "Accept License Agreement",
click the link and it will download jdk-8u66-windows-x64.exe.

Install jdk-8u66-windows-x64.exe
Remember the install path C:\Program Files\Java\jdk1.8.0_66\

To be able to use Java from the command-line we need to configure our 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

Alternatively you can also edit .profile from Sublime Text
open the path C:\cygwin\home\username\.profile

export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.8.0_66"

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

note: don't forget the quotes, you need them to support spaces in the directory path eg. "Program Files"

Apply the changes
$ source .profile

Test Java
$ java -version

You should obtain something like

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)

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

...
# if running bash
if [ -n "${BASH_VERSION}" ]; then
  if [ -f "${HOME}/.bashrc" ]; then
    source "${HOME}/.bashrc"
  fi
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="/cygdrive/c/Program Files/Java/jdk1.8.0_66"

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

alias ls="ls --color=auto"
alias tree="tree -C"
Ant

Download Ant from http://ant.apache.org/bindownload.cgi.

For example apache-ant-1.9.6-bin.zip

Optional:
It would be nice to access download files form the command-line
in the terminal create a symlink
$ ln -s /cygdrive/c/Users/$USER/Downloads downloads
yes you can use an environmentvariable in the path
here $USER will resolve to your username

Go to your download directory
$ cd ~/downloads

Unzip the file
$ unzip apache-ant-1.9.6-bin.zip

If you obtain
-bash: unzip: command not found
simply install it
$ apt-cyg install unzip

Now we have many choices to install Ant

  • move the directory to C:\Program Files\
    or even C:\Program Files\Java\
  • move the directory to /opt/local/share/java (like with Mac OS X)
  • move the directory to /usr/share/ant (like with Mac OS X)

POSIX would want us to have an executable in /usr/bin/ant
so here what we gonna do

  • move the directory to /usr/share/apache-ant-1.9.6
  • rename it to /usr/share/ant
  • then add a symlink of /usr/share/ant/bin/ant to /usr/bin/ant
  • then add the ANT_HOME env var to our .profile

Yep we do follow POSIX as much as we can, so let's do it:

  • you are in the terminal
  • you are in your downloads directory
    $ cd ~/downloads
  • move the folder
    $ mv apache-ant-1.9.6 /usr/share/apache-ant-1.9.6
  • you will get an error
    mv: cannot move 'apache-ant-1.9.6' to '/usr/share/apache-ant-1.9.6': Permission denied

In fact, you would obtain the same error under Mac OS X and Linux, some directories and/or files can only be manipulated by the root user, and to do that you need to use the command sudo.

The problem is that under Windows, there is no root user but an Administrator user.

But ultimately you just need a way to elevate the privileges of your current user to be seen as the root user from the cygwin perspective.

So let's do that and add a sudo command
(see Stackoverflow - Root user/sudo equivalent in Cygwin?)

go to the bin directory
$ cd /bin
create the sudo file
$ touch sudo
make it executable
$ chmod +x sudo
edit it
$ nano sudo

with this content

#!/usr/bin/bash
cygstart --action=runas "$@"

save and exit

now let's try again

  • you are in the terminal
  • you are in your downloads directory
    $ cd ~/downloads
  • move the folder
    $ sudo mv apache-ant-1.9.6 /usr/share/apache-ant-1.9.6
    you will get a popup, answer "Yes"
  • now change your path to /usr/share
    $ cd /usr/share
  • and rename apache-ant-1.9.6 to ant
    $ sudo mv apache-ant-1.9.6/ ant
    you will get a popup, answer "Yes"
  • you can go back to your home folder
    $ cd ~
  • now create the symlink
    $ ln -s /usr/share/ant/bin/ant /usr/bin/ant

Test if you can use Ant
$ ant -version

You will obtain

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_66\lib\tools.jar
Apache Ant(TM) version 1.9.6 compiled on June 29 2015

Something is missing, you need to edit your .profile
$ nano ~/.profile

add the following

export ANT_HOME=/usr/share/ant/

Apply the changes
$ source ~/.profile

Try again
$ ant -version

and now you should obtain

Apache Ant(TM) version 1.9.6 compiled on June 29 2015

you can check your different HOME env vars like that
$ printenv | grep HOME
result

HOMEPATH=\Users\zwetan
ANT_HOME=/usr/share/ant/
JAVA_HOME=/cygdrive/c/Program Files/Java/jdk1.8.0_66
HOME=/home/zwetan
HOMEDRIVE=C:
Flex SDK

We want to install all SDK in the C:\sdk folder
and we want all Flex SDK to be in the C:\sdk\flex folder

  • open the Terminal
  • go to the C drive
    $ cd /cygdrive/c
  • create the directories path
    $ mkdir -p sdk/flex

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

  • go into our flex sdk folders
    $ cd /cygdrive/c/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 C:\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 /cygdrive/c/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.zip
  • unzip it into the folder "4_14_1"
    $ unzip apache-flex-sdk-4.14.1-bin.zip -d 4_14_1
  • do not delete "apache-flex-sdk-4.14.1-bin.zip"
    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=3.0 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=c:/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 C:\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.

Visual Studio

Download Download Visual Studio 2010 Express All-in-One
you will obtain VS2010Express1.iso

  • select VS2010Express1.iso
  • right click "Mount"
    it should show as "DVD Drive (E:) VS2010Express"
  • double click the file Setup.hta
  • click "Visual C++ 2010 Express"
  • we don't need optional products like
    Silverlight and MS SQL Server etc...
    so just unselect them
  • let's remember the install path
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\

We want to support 64-bit compilation

64-bit tools are not available on Visual C++ 2010 Express by default

Download Microsoft Windows SDK for Windows 7 and .NET Framework 4
(also known as Windows SDK v7.1)
you will obtain winsdk_web.exe

  • double click winsdk_web.exe
  • in the "Installation Options"
    in "Redistributable Packages"
    unselect "Microsoft Visual C++ 2010"
  • install

you must also install KB2519277 to restore the 64-bit
compilers and libraries. Otherwise, an error occurs
when you attempt to configure a project to target a 64-bit platform.

KB2519277

FIX: Visual C++ compilers are removed when you upgrade
Visual Studio 2010 Professional or Visual Studio 2010 Express
to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed

Download Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1
you will obtain VC-Compiler-KB2519277.exe, double click to install it.

Configure your Visual Studio 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

add Visual Studio environment variables

# NOTE: The INCLUDE, LIB and LIBPATH must contain windows path information and separator and not cygwin paths.
VS_HOME_PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0"
VS_HOME="c:\Program Files (x86)\Microsoft Visual Studio 10.0"
VS_SDK="C:\Program Files (x86)\Microsoft SDKs\Windows"

export INCLUDE="$VS_HOME\VC\atlmfc\include;$VS_HOME\VC\include;$VS_SDK\v7.0A\Include"
export LIB="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib;$VS_SDK\v7.0A\Lib"
export LIBPATH="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib;$VS_SDK\v7.0A\Lib"

and edit your path

export PATH="$JAVA_HOME/bin:$VS_HOME_PATH/Common7/IDE:$VS_HOME_PATH/VC/bin:$VS_HOME_PATH/Common7/Tools:$VS_HOME_PATH/VC/vcpackages:$PATH"

To apply the changes
$ source .profile

Let's test on the command-line
$ cl

you should obtain

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

not good

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86

If you try to compile a redtamarin 64-bit executable you will obtain an error about not finding ml64.exe.

we want a 64-bit compiler, linker, etc.
change
$VS_HOME_PATH/VC/bin
to
$VS_HOME_PATH/VC/bin/amd64

and edit your path

export PATH="$JAVA_HOME/bin:$VS_HOME_PATH/Common7/IDE:$VS_HOME_PATH/VC/bin/amd64:$VS_HOME_PATH/Common7/Tools:$VS_HOME_PATH/VC/vcpackages:$PATH"

Your profile should look like the following

...
# This file is not read by bash(1) if ~/.bash_profile or ~/.bash_login
# exists.
#
# if running bash
if [ -n "${BASH_VERSION}" ]; then
  if [ -f "${HOME}/.bashrc" ]; then
    source "${HOME}/.bashrc"
  fi
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:"

# NOTE: The INCLUDE, LIB and LIBPATH must contain windows path information and separator and not cygwin paths.
VS_HOME_PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0"
VS_HOME="c:\Program Files (x86)\Microsoft Visual Studio 10.0"
VS_SDK="C:\Program Files (x86)\Microsoft SDKs\Windows"

export INCLUDE="$VS_HOME\VC\atlmfc\include;$VS_HOME\VC\include;$VS_SDK\v7.0A\Include"
export LIB="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib;$VS_SDK\v7.0A\Lib"
export LIBPATH="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib;$VS_SDK\v7.0A\Lib"

export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.8.0_66"
export ANT_HOME=/usr/share/ant/


export PATH="$JAVA_HOME/bin:$VS_HOME_PATH/Common7/IDE:$VS_HOME_PATH/VC/bin/amd64:$VS_HOME_PATH/Common7/Tools:$VS_HOME_PATH/VC/vcpackages:$PATH"

alias ls="ls --color=auto"
alias tree="tree -C"

Test again on the command-line
$ cl

you should obtain

Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

that's what we want

Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64

It's a good start but that's not enough, in fact what we really want is to be able to switch between the 32-bit and 64-bit setup on the spot, and to do just that we will need to heavily edit our .profile, here the full script

# Set user-defined locale
export LANG=$(locale -uU)

# This file is not read by bash(1) if ~/.bash_profile or ~/.bash_login
# exists.
#
# if running bash
if [ -n "${BASH_VERSION}" ]; then
  if [ -f "${HOME}/.bashrc" ]; then
    source "${HOME}/.bashrc"
  fi
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="/cygdrive/c/Program Files/Java/jdk1.8.0_66"
export ANT_HOME=/usr/share/ant/

# START VS CONFIG
VS_HOME_PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0"
VS_HOME="c:\Program Files (x86)\Microsoft Visual Studio 10.0"
VS_SDK="C:\Program Files\Microsoft SDKs\Windows"

# IMPORTANT:
# if VS_ARCH is empty or not set
# we default to 32-bit 
# 
# to switch between 32-bit and 64-bit VS build toolchain
# for 32-bit use:
# $ export VS_ARCH=32; source ~/.profile
# for 64-bit use:
# $ export VS_ARCH=64; source ~/.profile
if [ -z "$VS_ARCH" ]; then
	export VS_ARCH=32
fi

if [ $VS_ARCH = "32" ]; then
	# NOTE:
	# The INCLUDE, LIB and LIBPATH must contain windows path information and separator and not cygwin paths.
	export INCLUDE="$VS_HOME\VC\atlmfc\include;$VS_HOME\VC\include;$VS_SDK\v7.1\Include"
	export LIB="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib;$VS_SDK\v7.1\Lib"
	export LIBPATH="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib;$VS_SDK\v7.1\Lib"
	VS100PATH="$VS_HOME_PATH/Common7/IDE:$VS_HOME_PATH/VC/bin:$VS_HOME_PATH/Common7/Tools:$VS_HOME_PATH/VC/vcpackages"
	export PATH="$VS100PATH:/usr/local/bin:/usr/bin:$ORIGINAL_PATH"
else
	# NOTE:
	# The INCLUDE, LIB and LIBPATH must contain windows path information and separator and not cygwin paths.
	export INCLUDE="$VS_HOME\VC\atlmfc\include;$VS_HOME\VC\include;$VS_SDK\v7.1\Include"
	export LIB="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib\amd64;$VS_SDK\v7.1\Lib\x64"
	export LIBPATH="$VS_HOME\VC\atlmfc\lib;$VS_HOME\VC\lib\amd64;$VS_SDK\v7.1\Lib\x64"
	VS100PATH="$VS_HOME_PATH/Common7/IDE:$VS_HOME_PATH/VC/bin/amd64:$VS_HOME_PATH/Common7/Tools:$VS_HOME_PATH/VC/vcpackages"
	export PATH="$VS100PATH:/usr/local/bin:/usr/bin:$ORIGINAL_PATH"
fi

export CL_MPCount=4
# END VS CONFIG


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

alias ls="ls --color=auto"
alias tree="tree -C"
alias build32="export VS_ARCH=32; source ~/.profile"
alias build64="export VS_ARCH=64; source ~/.profile"
alias vsarch="echo 'Visual Studio is setup for $VS_ARCH-bit compilation'"

# echo "=== build $VS_ARCH-bit ==="
# echo "PID = $$"
# echo "LANG = $LANG"
# echo "VS_ARCH = $VS_ARCH"
# echo "PATH = $PATH"
# echo "===================="

Usage

zwetan@gamma ~
$ vsarch
Visual Studio is setup for 32-bit compilation

zwetan@gamma ~
$ build64

zwetan@gamma ~
$ vsarch
Visual Studio is setup for 64-bit compilation

zwetan@gamma ~
$ build32

zwetan@gamma ~
$ vsarch
Visual Studio is setup for 32-bit compilation

If you plan to build/test 32-bit compilation only
$ build32
then only build 32 bit form the ant build
$ ant
and vise versa for 64-bit

But if you plan to build both 32-bit and 64-bit you
you can not use ant directly
you will need to use this special script
$ build/build32and64

Here its content

#!/bin/bash

# 32-bit build
exec > >(tee ./out1.file) 2>&1

export VS_ARCH=32
source "$HOME/.profile"
ant -Dbuild.32bit=true -Dbuild.64bit=false

time1=$(cat ./out1.file | grep "Total time" | awk -F": " '{ print $2 }')

retcode32=$?
if [[ $retcode32 != 0 ]] ; then
	echo "BUILD FAILED (32-bit)"
	echo "Total time: $time1"
	exit $retcode32
fi

# echo "BUILD SUCCESSFUL (32-bit)"
# echo "Total time: $time1"

# 64-bit build
exec > >(tee ./out2.file) 2>&1
rm ./out1.file

export VS_ARCH=64
source "$HOME/.profile"
ant -Dbuild.32bit=false -Dbuild.64bit=true

time2=$(cat ./out2.file | grep "Total time" | awk -F": " '{ print $2 }')

retcode64=$?
if [[ $retcode64 != 0 ]] ; then
	echo "BUILD FAILED (64-bit)"
	echo "Total time: $time2"
	exit $retcode64
fi

echo ""
echo "BUILD SUCCESSFUL (32-bit)"
echo "Total time: $time1"
echo "BUILD SUCCESSFUL (64-bit)"
echo "Total time: $time2"

rm ./out2.file

That's basically what we use when we want to build all 32-bit and 64-bit executable.

Building Tools

Because the compilation depends on make we need to install it
$ apt-cyg install make

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

for example: with the redshell_dd.exe 64-bit
original size: 6.5M redshell_dd.exe (6745600 bytes)
after $ upx -9 redshell_dd.exe
packed size: 1.3M redshell_dd.exe (1351168 bytes)

Use file to check the exe
for example in /bin-release/windows/64/debugger/
$ file redshell_dd.exe
result:
redshell_dd.exe: PE32+ executable (console) x86-64, for MS Windows

for example in /bin-release/windows/32/debugger/
$ file redshell_dd.exe
result:
redshell_dd.exe: PE32 executable (console) Intel 80386, for MS Windows

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

        ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffc80820000)
        KERNEL32.DLL => /cygdrive/c/Windows/system32/KERNEL32.DLL (0x7ffc7e540000)
        KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7ffc7de90000)
        WINMM.dll => /cygdrive/c/Windows/SYSTEM32/WINMM.dll (0x7ffc75800000)
        ADVAPI32.dll => /cygdrive/c/Windows/system32/ADVAPI32.dll (0x7ffc7e250000)
        WS2_32.dll => /cygdrive/c/Windows/system32/WS2_32.dll (0x7ffc7e300000)
        PSAPI.DLL => /cygdrive/c/Windows/system32/PSAPI.DLL (0x7ffc7e520000)
        WINMMBASE.dll => /cygdrive/c/Windows/SYSTEM32/WINMMBASE.dll (0x7ffc757b0000)
        msvcrt.dll => /cygdrive/c/Windows/system32/msvcrt.dll (0x7ffc80410000)
        USER32.dll => /cygdrive/c/Windows/system32/USER32.dll (0x7ffc806a0000)
        sechost.dll => /cygdrive/c/Windows/SYSTEM32/sechost.dll (0x7ffc7e900000)
        RPCRT4.dll => /cygdrive/c/Windows/system32/RPCRT4.dll (0x7ffc7e110000)
        NSI.dll => /cygdrive/c/Windows/system32/NSI.dll (0x7ffc80170000)
        cfgmgr32.dll => /cygdrive/c/Windows/SYSTEM32/cfgmgr32.dll (0x7ffc7e050000)
        DEVOBJ.dll => /cygdrive/c/Windows/SYSTEM32/DEVOBJ.dll (0x7ffc7ca30000)
        GDI32.dll => /cygdrive/c/Windows/system32/GDI32.dll (0x7ffc80180000)
        IMM32.DLL => /cygdrive/c/Windows/system32/IMM32.DLL (0x7ffc7e8c0000)
        MSCTF.dll => /cygdrive/c/Windows/system32/MSCTF.dll (0x7ffc802d0000)
Conflict and other errors

If the build complain about some option not found with link.exe it is because there are 2 link.exe files

one can be located in Cygwin /usr/bin or C:\cygwin\bin and is a Cygwin utility

Usage: link FILE1 FILE2
  or:  link OPTION
Call the link function to create a link named FILE2 to an existing FILE1.

      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/link>
or available locally via: info '(coreutils) link invocation'

the other (the one we want to use) is located at /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/ and is the linker

Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.
...

To solve that conflict simply rename the Cygwin utility
$ mv /usr/bin/link.exe /usr/bin/_link.exe

SSH Server

Optional

IMPORTANT
Be sure to configure this last (eg. after the whole "The Development Stack").

In the default packages we installed for cygwin we used openssh which allow us to shh into another machine but also allow us to setup a ssh server, so other machines can ssh to us.

  • Open a Terminal
  • To configure the ssh server we need to be admin
    but by default our current terminal is not
    so we need to open another one with admin rights
    $ sudo bash --login -i
    answer "Yes"
  • configure ssh
    $ ssh-host-config
    • if you don't have admin rights you will see warnings

*** Warning: Running this script typically requires administrator privileges! *** Warning: However, it seems your account does not have these privileges. *** Warning: Here's the list of groups in your user token: ... *** Warning: This usually means you're running this script from a non-admin *** Warning: desktop session, or in a non-elevated shell under UAC control.

*** Warning: Make sure you have the appropriate privileges right now, *** Warning: otherwise parts of this script will probably fail!

*** Query: Are you sure you want to continue? (Say "no" if you're not sure *** Query: you have the required privileges) (yes/no) no ```

  • from that point you should see
    *** Info: Generating missing SSH host keys
    with *** Info in green, meaning you have admin rights
    so continue answering the questions
  • *** Query: Should StrictModes be used? (yes/no)
    no
  • *** Query: Should privilege separation be used? (yes/no)
    no
  • *** Query: Do you want to install sshd as a service?
    (Say "no" if it is already installed as a service) (yes/no)
    yes
  • *** Query: Enter the value of CYGWIN for the daemon: []
    binmode ntsec
  • *** Query: Do you want to use a different name? (yes/no)
    no
  • *** Query: Create new privileged user account 'MACHINENAME\cyg_server' (Cygwin name: 'cyg_server') (yes/no)
    yes
  • *** Query: Please enter the password:
    (type the password you want)
  • *** Query: Reenter:
    (type the password you want again)
  • you should get a bunch of lines ending with
    *** Info: Host configuration finished. Have fun!
  • you can close this second bash window
  • in the first window, start the service
    $ sudo cygrunsrv -S sshd
    answer "Yes"

Verify that the service is installed and running

  • right click on "My Computer"
  • select "Manage"
  • In the Computer Management window, in the left pane
    expand "Services and Applications"
  • select "Services"
  • In the right pane
    locate "CYGWIN sshd"
    check if the status is "Running"

Configure the Windows firewall

  • open the "Control Panel"
  • select "System and Security"
  • select "Windows Firewall"
  • on the left click "Advanced settings"
  • in the left pane select "Inbound Rules"
  • right click "New Rule..."
  • for "Rule Type"
    select Port
  • for "Protocol and Ports"
    select TCP
    select Specific local ports:
    enter 22
  • for "Action"
    select Allow the connection
  • for "Profile"
    select only Private
    (the plan is to connect to this computer
    only on the local network, it could also
    work on other networks but we advise against it)
  • for "Name"
    enter sshd

Now we can ssh into this machine from another machine
$ ssh [email protected]
you should see
[email protected]'s password:
(enter your password)

note:
This mainly allow us to run a build on a windows machine
from the command line of another machine.
For example: I work mainly under OS X, with that I can
from my OS X Terminal run the build of the Linux and Windows
machines without opening RDP sessions.
Yes, automation :).

SDK

TODO

Redtamarin

We want to work from a folder named "work"

  • open the Terminal
  • go to the C drive
    $ cd /cygdrive/c
  • create the directory "work"
    $ mkdir work

Follow the directions in Compiling Redtamarin.

Misc.

Create a bootable USB to install Windows

Follow the instructions from How do I create a bootable flash drive for installing Windows?.

Under Mac OS X Yosemite I used

Creating a Windows flash drive installer on an OS X computer

  1. From the Finder, open the Applications folder, and then Utilities.

  2. Open the Boot Camp Assistant, and then click Continue. The next screen should give you a list of options.

  3. UITS recommends making the USB drive installer first. You don't need to install Windows or download the support software at this time, as it will be easier to do both later. To proceed:

a. Verify that the USB drive you will be writing to is plugged in.

b. Uncheck the Install Windows 7 or later version and Download the latest Windows support software from Apple options.

c. Check Create a Windows 7 or later install disk and click Continue.

  1. Your USB drive should be listed in the "Destination disk" area. Use choose to browse to your .iso file; after selecting it, click Continue.

  2. If prompted, confirm your action and/or provide an administrator's password. The process of writing the .iso file to the USB drive can take 20 minutes or longer.

3b is extremely important, if you don't uncheck those options the USB will boot but the UEFI boot written will fail.

Hardware

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

To have a painless experience be sure to have the latest BIOS, mine had F7 by default (which was OK) but others had some issues with earlier version like F2, F4, etc.

In the BIOS, you can select either "Windows 7" or "Windows 8", selecting "Windows 8" flawlessly installed Windows 8.1 64-bit.

If you're new to UEFI boot, be sure to plug first your bootable USB key and then go into the BIOS to select it to boot first.

The installation process is straightforward, the Wifi works no need to use an ethernet cable.

Once Windows is installed be sure to install all the drivers, in my case I installed all the Windows 8.1 64-bit drivers.

Everything works but without those drivers some devices are seen as unrecognised (yellow mark) in the "Device Manager", for example: installing the Realtek audio drivers did not activate the sound on the HDMI but when I installed the Intel Display drivers the sound then worked while connected in HDMI.

Here some more reference

Clone this wiki locally