Showing posts with label virtualbox. Show all posts
Showing posts with label virtualbox. Show all posts

Tuesday, September 15, 2015

Allowing secondary monitor for VirtualBox (5.0.4) VM in three easy steps

1. Power off VM. Go to Settings->Display, change number of monitors to 2. Add video memory if there is a warning.
2. Run the VM. Open View->Virtual screen 2 menu and select "Enabled". The second VM window appears.
3. As per your VM OS go to Settings / Control Panel and modify Display so the OS can use both monitors, just like with the normal Windows or Linux computer. For Ubuntu it is Settings->Display, for Windows you can right-click on desktop background and select "Screen Resolution..." menu.

Installing Ubuntu 14.04 in VirtualBox for NGiNX modules development

For teh first time, after many years with RHEL / FEdora / CentOS family I decded to give a try to Ubuntu. Why? First, because it is the Linux of choice at AWS, after Amazon Linux of course.
Second, in order to learn something different. Third, in order to make some comparison by myself.

First surprise with Ubuntu 14.04.03 which I installed with Oracle VirtualBox (I gave this development VM 4 CPUs, 12 GB RAM, 40GB HD) is that there is no root access. I defined a user during the install and this user got 'sudo' permissions. So either I have to write 'sudo' every time or allow root access. The latest is not recommended, and this explains why the root access is by default disabled at Ubuntu. In general, I agree with the idea that there is no need to run any user process as a root, and for any system I develop I actually define a specific user which such a system uses. So let's see if I can manage it without enabling root account.

After installing a basic server configuration I wanted to add a Desktop so I could add development IDE there. The only thing I needed to run was:
sudo apt-get install ubuntu-desktop
(as per this link) followed by reboot did the job. Next, I added VBox Guest Additions and got a full-screen resizable Desktop. After that I started to look how I can open a terminal window :). This was a real challenge since "Search" for 'xterm' using top-left Ubuntu icon only gave me the reference documentation for that. It did not run the terminal process though.
CTR-ALT-T worked, but I could not find any other app as well, even not a web browser.

Since I do dnot save the snapshot for teh basic server install I decided to give up and re-installed Ubuntu 14.04 server. Once the basic server install was completed I ran
sudo apt-get --install-recommends install ubuntu-desktop
It took about 15 minutes on my i7 Windows 8.1 machine to install all the required packages, and than I got a black screen with no text. As per System Monitor the VirtualBox process was keep writing things on disk and kept using CPU. First time it happened I killed the process after 10 minutes or so and started over. Next time it happened again, so I decided to give it a chance and left it open.
At the end I found out that I just had to press ENTER and the text is now shown again!
sudo reboot now.
I started VirtualBox Guest Additions CDROM, than Rebooted the machine (had to repeat it twice until it worked) and got teh working Desktop environment.

All-in-all, about 4h to get there with trial and errors.

Next, I installet NetBeans 8.1beta for C++/Java/Scala development. It requested to install JDK (8u60). I also had to install GNU C++ compiler:
sudo apt-get install g++
and CMake
sudo apt-get install cmake
I also had to install PCRE, zlib and a few more librbaries on Ubuntu in order to properly build quite a minimal configuration of NGiNX from the sources:
sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev build-essential libssl-dev

Now I configured NGiNX from the source to be installed in a development path:
cd ; ./configure --prefix=/home/david/dev/nginx
It created Makefile in that folder. I started NetBeans with "New C/C++ project from existing source", pointed to that  and got the Netbeans project for NGiNX.

I had to modify Netbeans project (Right-click on project -> Properties)
adding
${MAKE} -f Makefile install 
instead of 
${MAKE} -f Makefile
to Build section,
and adding 
./configure --prefix=/home/david/dev/nginx
to Pre-build section (check "Pre-build" checkbox!)
After all, I got an IDE-compiled running NGiNX.



Monday, July 22, 2013

Installing Qt 5.1 on a virtual CentOs 6.4 server

1. Get the latest VirtualBox software from https://www.virtualbox.org/wiki/Downloads

2. Get CentOS 6.4 DVDs or ISO files from the Internet, e.g.here:
http://mirrors.usc.edu/pub/linux/distributions/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso and here http://mirrors.usc.edu/pub/linux/distributions/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD2.iso

Install CentOS VM with 4-5GB RAM, 4-6 CPUs and 40GB HD.

System->Administartion->Software Update - install the updates
Devices->Install Guest Additions
System->Preferences-Screen Saver: unselect "Activate when idle"

Restart the VM


#If the VM HD needed to be later resized
#>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd
#"C:\Users\david_000\VirtualBox VMs\AdEx2 CentOS 6.4_ QT 5.1\AdEx2 CentOS 6.4_ QT 5.1.vdi" --resize 32768

3. Build the latest GCC from the sources, e.g. from http://gcc.cybermirror.org/releases/gcc-4.8.1
mkdir ~/tmp
cd ~/tmp

tar -jxvf ~/Downloads/gcc-4.8.1.tar.bz2

cd gcc-4.8.1
./contrib/download_prerequisites
mkdir gcc-build
cd gcc-build
sudo ../configure --disable-multilib
sudo make
sudo make install



4. Edit ~/.bash_profile adding there

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
export LD_LIBRARY_PATH


#save & close the file, init the environment in your terminal
source ~/.bash_profile


5. Download Qt
su

#install missing gstreamer packages, if any
yum install 'pkgconfig(gstreamer-app-0.10)'


mkdir /tmp/qt
cd /tmp/qt
wget http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz

# for QT 5.2: wget http://www.mirrorservice.org/sites/download.qt-project.org/official_releases/qt/5.2/5.2.0/single/qt-everywhere-opensource-src-5.2.0.tar.gz

tar -xvf qt-everywhere-opensource-src-4.8.5.tar.gz
cd qt-everywhere-opensource-src-4.8.5
#For Qt 4.8.5:  ./configure
#For Qt5.x:  ./configure -qt-xcb
make
make install

#If your shell is bash, ksh, zsh or sh modify ~/.profile file adding:
PATH=/usr/local/Trolltech/Qt-4.8.5/bin:$PATH
export PATH

LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.8.5/bin:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH


#in case your shell is csh or tcsh modify ~/.login adding:
setenv PATH /usr/local/Trolltech/Qt-4.8.5/bin:$PATH


4. Install the new virtual machine with CentOS 6.4, select "Minimal Desktop" / RedHat in VirtualBox settings, 4GB RAM
  -- VirtualBox->Devices -> Shared Clipboard -> Bidirectional
  -- VirtualBox->Devices ->Drag-n-Drop-> Bidirectional
  -- VirtualBox->Devices->Install Guest Additions
  -- Network->eth0->connect automatically
  -- System->Preferences->Screensaver - unselect "Auto"


5. Create a new user and add him to sudoers (visudoers as root). Also add
Defaults: root !requirestty
Defaults:your-new-user !requirestty


7. Install QtCreator if required.
cd ~/Qt

# QtCreator 2.8 fails with Segmentation fault  (core dumped) error
# wget http://download.qt-project.org/official_releases/qtcreator/2.8/2.8.0/qt-creator-2.8.0-src.tar.gz
# gzip -d qt-creator-2.8.0-src.tar.gz
# tar -xvf qt-creator-2.8.0-src.tar
# cd  qt-creator-2.8.0-src

# using 2.7.0 instead of failing 2.8.0

wget http://origin.releases.qt-project.org/qtcreator/2.7.0/qt-creator-2.7.0-src.tar.gz
gzip -d  qt-creator-2.7.0-src.tar.gz
tar -xvf qt-creator-2.7.0-src.tar
cd qt-creator-2.7.0-src


sudo /usr/local/Qt-5.1.0/bin/qmake qtcreator.pro

# if an error occures:
# error: dereferencing pointer ‘’ does break strict-aliasing rules
# Then edit corresponding Makefile removing "strict" flag (the build fails otherwise)

# Open in an editor and remove "-Werror" in CXXFLAGS variable
# vi /home/bis/Qt/qt-creator-2.8.0-src/src/shared/qbs/src/lib/Makefile


sudo gmake
sudo gmake install

#check install:
which qtcreator

#should return
/bin/qtcreator